How to find out if cronjob is working (python command is running)

When I run this command, the output message is saved to the ok.txt file:

 /home/admin/virtualenvs/x.com/bin/python /home/admin/www/x.com/x/app/manage.py help | tee ok.txt

I have this cronjob:

* * * * * /home/admin/virtualenvs/x.com/bin/python /home/admin/www/x.com/x/app/manage.py help | tee ok.txt

But nothing is saved in ok.txt

When I see the cron log

> sudo grep CRON /var/log/syslog

May 10 22:16:01 localhost CRON[23397]: (admin) CMD (/home/admin/virtualenvs/x.com/bin/python /home/admin/www/x.com/x/app/manage.py help | tee ok.txt)

There are no hints here, what am I doing wrong? thanks in advance.

+3
source share
2 answers

try the following:

* * * * * /home/admin/virtualenvs/x.com/bin/python /home/admin/www/x.com/x/app/manage.py help > /tmp/ok.txt 2&>1

it should put all outputs (stderr and stdout) in your ok.txt file

+1
source

I see first that you do not have the correct syntax for crontab:

Example of job definition:
.---------------- minute (0 - 59)
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|  |  |  |  |
*  *  *  *  * user-name command to be executed

You are missing a username.

. , .bashrc . cron , . , script -, bashrc, , .

0

All Articles