Ruchi
Ruchi

Reputation: 5192

crontab doesnt work in linux

My Linux version is red hat enterprise linux server release 5.3 tikanga

i have schedule crontab as below

1 * * * * /usr/testjob.sh  2>&1 >> /usr/result.txt

crontab job not running on scheduled time...

Please suggest..

Upvotes: 1

Views: 553

Answers (3)

Daniel YC Lin
Daniel YC Lin

Reputation: 15992

Try this at first.

* * * * * /usr/testjob.sh

Then you may received a mail for every minutes. Check the error output. Sometimes, it may caused by your default shell is just sh instead of bash.

So, maybe ">>" is not supported.

You should check do you have /usr permission when you want to write into it.

Upvotes: 1

ivoba
ivoba

Reputation: 5986

just to mention it and make sure

NOTE: Each cron table entry must have a trailing line break in order for the cron table entry to be recognized.

Upvotes: 0

Denis Arnaud
Denis Arnaud

Reputation: 388

As said by +Shawn Chin, if you want to run your command only once, the at command is your friend.

If you want to run your command repeatedly, then you are right to use the cron framework. The manual page explaining the fields of the crontab may be obtained with the following command:

$ man -s 5 crontab

You appear to be in an Indian time-zone (IST). You may have to specify that into the crontab. For instance, using the 'crontab -e' command (to save and quit, type 'ESC-wq', as the editor is VI by default):

#
CRON_TZ=IST
# run at 06:33 (am), every day
33 06 * * *       /usr/testjob.sh  >> /usr/result.txt 2>&1

Note that '2>&1' should be placed AFTER '>> /usr/result.txt', not before.

Upvotes: 1

Related Questions