0

It runs by hand when I execute:

python /var/lib/mongodb/script.py >> /var/lib/mongodb/script.log 2>&1

But using cronjob, I see that script is executed but no output in /var/lib/mongodb/script.log

sudo -u mongodb crontab -l
* * * * * python /var/lib/mongodb/script.py >> /var/lib/mongodb/script.log 2>&1

on /var/log/syslog I see that cron is executed but no output in /var/lib/mongodb/script.log and the script.py is not running.

Update:

I tried with a test.py script and is working:

root@jessie:~# ls -al /var/lib/mongodb/test.py -rw-r--r-- 1 root root 184 May 10 13:49 /var/lib/mongodb/test.py

root@jessie:~# sudo -u mongodb crontab -e * * * * * python /var/lib/mongodb/test.py >> /var/lib/mongodb/test.log 2>&1

May 10 14:02:01 jessie CRON[1889]: (mongodb) CMD (python /var/lib/mongodb/test.py >> /var/lib/mongodb/test.log 2>&1)

root@jessie:~# ls -al /var/lib/mongodb/test.log -rw-r--r-- 1 mongodb nogroup 1792 May 10 14:04 /var/lib/mongodb/test.log

The test.py script contains:

print "Hello World!" print "Hello Again" print "I like typing this." print "This is fun." print 'Yay! Printing.'

basante
  • 515
  • 3
  • 9
  • 20

1 Answers1

0

Your .py file is not executable; use chmod +x and try to run cron job again.

Similar case here. Making file executable helped.

Wojtek_B
  • 4,245
  • 1
  • 7
  • 21