2

I have made a mistake, I have edited /etc/crontab via copy and paste. And now those crontab entries are not working.

[root@process ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
*/5 * * * * root php /var/www/vhosts/mydomain.com/subdomains/apn/httpdocs/sdkstatistics/callEveryFiveMinute.php 2>&1 /tmp/testlog.log

Later I studied, and found that I should not edit crontab via copy and paste. Rather I have to use crontab -e to add crontab.

I have run the crontab -l command to show the current listing

[root@process ~]# crontab -l
7,17,27,37,47,57 *  *  *  * /usr/lib/plesk-9.0/postfix-poplockdb-clean
1,16,31,46  *   *   *   *   /usr/local/psa/admin/sbin/backupmng >/dev/null 2>&1

Here, my last entry */5 * * * * root php /var/www/vhosts/mydomain.com/subdomains/apn/httpdocs/sdkstatistics/callEveryFiveMinute.php 2>&1 /tmp/testlog.log is not listed.

Now can i revert back to my previous state? Or, better what should I do?

1 Answer 1

3

You don't say which distro or version of the cron daemon you are running, but it is likely that your cron maintains system crontab files (/etc/crontab) and also per-user crontab files.

The file that you are seeing when you run crontab -l (as root) is probably /var/spool/cron/crontabs/root which is where you want to make your changes, by using crontab -e

Without further information on your distro version or cron daemon, I won't go on, but it is possible you have broken the /etc/crontab as it has a slightly different syntax to the per-user crontab files. See

man cron 

man crontab

and

man 5 crontab

for more details on your cron daemon configuration, then remove the erroneous line from /etc/crontab and either add it one of to the /etc/cron.* directories or to a users crontab file. You may find information on the error in /etc/crontab from the system log files in /var/log

1
  • Also, consider running your job as a non root user if root is not entirely necessary.
    – Keith
    Commented Nov 12, 2012 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .