cron Error: bad username; while reading /etc/cron.d file on Linux

I am getting the following error in my cron job log file /var/log/cron.log:
       Aug 22 01:59:01 server2 cron[7510]: Error: bad username; while reading /etc/cron.d/backups
I have job entry as follows to run a job at 00:50 every day for root user:
       50 0 * * * /etc/cron.d/backups
How do I fix this problem on Linux or Unix-like system?

You are getting this error because you forgot to set name of the user to run a cron job:


1 2 3 4 5 USERNAME /path/to/command arg1 arg2

    1: Minute (0-59)
    2: Hours (0-23)
    3: Day (0-31)
    4: Month (0-12 [12 == December])
    5: Day of the week(0-7 [7 or 0 == sunday])
    USERNAME - Name of the user
    /path/to/command  Script or command name to schedule

The correct syntax is as follows for root user to run a cron job at 00:50 every day:

50 0 * * * root /etc/cron.d/backups

To run as vivek user:

50 0 * * * vivek /etc/cron.d/backups

See our tutorial “HowTo: Add Jobs To cron Under Linux or UNIX?” for more information.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum