Showing results for 
Search instead for 
Did you mean: 

cron issue

Muhammad Ahmad
Frequent Advisor

cron issue


Good Day

we create a cron entry in an ordinary user account, like given below:

* * * * * /tmp/ > /tmp/scr.log

when above executes, the scr.log always found empty?

Given below tests have been performed to diagnose/resolve:

1. execute /tmp/ manually through ordinary user account, all the commands sequentially executes without any problem.

2. we have replaced already written commands in file with a single command like echo 'test-output' > /tmp/echo.out. and then run '' through cron; strangly it also run without any problem which is confusing me.

Now, some questions arose:

Why an echo command is executing through cron in and the other commands NOT?

Why other commands are running without any problem when running on CLI like

chmod +x /tmp/

it runs fine, but through cron it won't?

Muhammad Ahmad
Trusted Contributor

Re: cron issue


Can you try this..

* * * * * /tmp/ >> /tmp/scr.log

use append (>>) instead of diversion (>)
Yogesh M Puranik
Valued Contributor

Re: cron issue


Your checks :

1]Check cron daemon is working properly, by using other simple test script.

2]Arrange the cron entry as mentioned below,so that you will get the details of errors you will get while excuting.

***** /tmp/ 2>>/tmp/scr.log.

3]Check the shell you are keeping as a magic line while starting the script.

3]Check whther you ve any line which clears executable logs.

Please check and let me know result as well as share script contents to check.



Ganesan R
Honored Contributor

Re: cron issue

Hi Muhammad,

If you want to redirect the standard output and standard errors produced by the script to a file, you should use like below.

* * * * * /tmp/ > /tmp/scr.log 2>&1

or to avoid overwrite

* * * * * /tmp/ >> /tmp/scr.log 2>&1
Best wishes,


Re: cron issue

>when above executes, the scr.log always found empty?

It is possible you don't have PATH set properly for the command you want to execute, so you get no output. cron has a limited PATH. That's why it works when you do it manually.

Re: cron issue

Hi Muhammad,
As a test Spaces can be safely removed and if there is a problem executing you can also redirect the error message to the file

please try executing the following command via command line and check if it works

sh -x /tmp/>>/tmp/scr.log

this way you can confirm if there are any error that occurred executing the command

then could you try the following please

* * * * * /tmp/>>/tmp/scr.log 2>&1