I have a script which need to be run as cron job.

In the staging environment i could run the script as a cronjob. but in the production environment it is not working,

so i checked whether cron daemon is running on the production

ps -ax|grep cron

but this command gives me following error message.

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
 4120 ?        Ss     0:06 crond
13640 pts/6    S+     0:00 grep cron

could anybody explain me what is wrong with this command

# housekeeper script
* * * * * sh  /product/abc/tools/housekeeper.sh -t x
  • show output from crontab -l – B14D3 May 16 '12 at 6:32
  • i have updated the question with the output from crontab -l – kitis May 16 '12 at 6:34

You don't need the sh cron runs scripts using sh anyway. Capture the output of your script to a file and see what it's saying

* * * * * /product/abc/tools/housekeeper.sh -t x >/tmp/file.out 2>&1 

Also, cron emails errors to the user who is running the script so check their mail. Post any relevant information if you need further assistance.

  • could you tell me where can i find the cronjob log file – kitis May 16 '12 at 7:12
  • >/tmp/file.out 2>&1 says to redirect the stdout ans stderr of the job to /tmp/file.out so look at that file. – Iain May 16 '12 at 7:14
  • on the staging environment i can capture the output of my script.but in the production it is not happening.... So i want to find out why script is not running. since script is not running it does not produce the file.out even. is there a log file for crontab command. if so what is the locaiton – kitis May 16 '12 at 7:15
  • Check /var/log - depending on distro/configuration it could be in syslog,messages,cron-* etc – Iain May 16 '12 at 7:23
  • 3
    Then you need to get someone with suitable permissions to work with you - we can't help any further. – Iain May 16 '12 at 8:06

Try to put /product/abc/tools/housekeeper.sh -t x into bash script file like this:

/product/abc/tools/housekeeper.sh -t x

I know that this is ugly hack but cron sometimes have problems whith commands parameters.

After you create file add job to cron

* * * * * /dir/to/that/scriptfile.sh

  • 1
    Did you face such a problem about command parameters? I always run cron jobs with/without parameters and did not notice any problem. – Khaled May 16 '12 at 7:03
  • Yup i had problems with php script running from cron php -f and that solves my problem – B14D3 May 16 '12 at 7:56

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.