0

I put together a python script that takes the output of a command and emails it to me every morning at 8. When running it manually, it runs fine, however when my cron runs it I receive the following:

Traceback (most recent call last):
  File "/root/backup-mailer.py", line 50, in <module>
    backups = json.loads(subprocess.check_output(['restic', 'snapshots', '--json']))
  File "/usr/lib64/python2.7/subprocess.py", line 568, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Is it /usr/lib64/python2.7/subprocess.py that it's having issues with?

My crontab:

0       8       *       *       *       . /root/.restic-env; /usr/bin/python /root/backup-mailer.py

I know . /root/.restic-env; runs fine because I use it in another cron which is successful. I've also ran /usr/bin/python /root/backup-mailer.py which executes fine. As I say, it's only when it's ran as a cron that it fails.

Any suggestions? Thanks

Jam3sn
  • 119
  • 4
  • being run on centos selinux could be an issue. – Gerald Schneider Feb 09 '18 at 11:28
  • This is most probably an environment difference, as described in https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it section `cron runs your command in a restricted environment`. – Law29 Feb 09 '18 at 11:20
  • Right, which is why i provided the path for python and the file – Jam3sn Feb 09 '18 at 11:46

0 Answers0