Linux – Cron not running CentOS

centoscronlinuxshell

What am I doing wrong here? Trying to set a cron job to run a shell script but it won't work. I entered the below after doing crontab -e. It does show up when doing contrab -l.

0 2 * * * root /root/localbackup.sh

Best Answer

You're using the crontab format that's used for /etc/crontab. For the user crontabs you don't need to specify the user

 0 2 * * * /root/localbackup.sh

should run.


Answering the commants

The output from vi is normal, crontab will copy it to the correct location

  • Check that cron is running
  • Check that there is a newline at the end of your command (crontab -e and press return at the end of the line)
  • Check the root account's mail for any output that is mailed from cron.
  • Capture the output of the command 0 2 ... &>/tmp/mylog.log