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.

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....