Crontab - Simple Echo Not Running

Crontab - simple echo not running

May be it is, cron jobs will run in their own shell. So you can't expect to see asdf on your console.

What you should try is

* * * * * echo asdf > somefile_in_your_home_directory_with_complete_path.log

Next check the file by doing a tail:

tail -f somefile_in_your_home_directory_with_complete_path.log

And if it's not, check if the cron daemon itself is running or is down:

# pgrep crond

OR

# service crond status

Ubuntu crontab simple echo to file not working

you should paste the full path of script. For example 25 11 * * * /home/xxxx/test_script.sh

crontab not fully working. only echo statements being run

Including the path to bash shell might be needed:

* * * * * /bin/sh /home/sys_bio/username/tracer.sh >> ...

cron otherwise might not really know what to do.

The same principle also applies to what is included in your script. Using relative file names can fail since they are often not interpreted the same as if you were using your local interactive shell (eg):

test.json

It might be necessary to use the absolute paths (eg):

/full/path/to/test.json

EDIT: It's apparent from the error generated by Python the issue is definitely path related. Python is trying to locate the module in the path /home/sys_bio/username/p35/bin/python3.5 instead of two directories up in /home/sys_bio/username/. The fix would be to cd into the directory or by giving the absolute path to the module. By adding the following into the .sh script:

cd /home/sys_bio/username

Should allow the command following it to look for the module there instead of two levels down.

Cron Job Doesn't Run

The cronjob is running just fine, but the cron daemon (daemons in general as far as I know) have no access to stdout so cannot output messages to the terminal.

To test it you can, however, output what you want to a file using

*/1 * * * * echo "job every minute" >>$HOME/filename

which will output (and concatenate) the text to a file named "filename" in your home directory every minute.



Related Topics



Leave a reply



Submit