5

I am running the following command as root, on OpenSuse:

linux-gn77-PC:/home/harbir/project # crontab -e

when the editor opens up I type the following, as I want the command to be run at 2145 hours

45 21 * * * * /home/harbir/project/maildispatcher.sh  &> /tmp/mycommand.log

when I try to save the file, I get the following message

crontab: installing new crontab
"/tmp/crontab.WOxjzG":1: bad command
errors in crontab file, can't install.
Do you want to retry the same edit?

I want the output of the crontab to go the file /tmp/mycommand.log.

9

You have one field too many in the crontab line.

It should be

minute hour dayofmonth month dayofweek command

You have an asterisk character in place of the command.

Also, if you want a crontab entry to run as root, it's arguably cleaner to put it in a /etc/cron.d/ file than in root's own user-level crontab.

Note that system crontabs (i.e. /etc/cron*) have a subtly different format. There is an extra field after the dayofweek field that contains the name of the user to run the command as.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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