1

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..

7
  • To schedule a command at a specific time (and not periodically), take a look at the at command. To run every minute, use "* * * * *". Commented Nov 1, 2011 at 12:35
  • 2
    The order of redirections is wrong, please use >> /usr/result.txt 2>&1 Commented Nov 1, 2011 at 12:43
  • In which crontab file did you put that line? Using what commands? Commented Nov 1, 2011 at 12:46
  • @A.H. i m using command : cronntab -e Commented Nov 1, 2011 at 12:47
  • 1
    So as long as the script file is executable and the user has the permissions to write to /usr/result.txt it should work. Commented Nov 1, 2011 at 12:50

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

Very nice and welcome aboard. One other point for new users of crontab, the nmemonic (sp?) device I use to remember the correct order (as your example shows), is that starting at the left, and moving right, you are using larger values of time in each of the first 4 columns, min, hr, day-of-mon, mon, with 5 col the days-of-week as number, consult your man page for is Sun=0 or 7? Good luck to all.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.