Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Also, consider running your job as a non root user if root is not entirely necessary. –  Keith Nov 12 '12 at 14:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.