Just some tips from my end - how I would try to schedule the whole thing
1) Include a shebang
line at the top of the python script for picking up the python executable and remove the python executable path from the cron
entry - there is always the off chance that the paths for the executables are different on productions server from development environment.
#!/usr/bin/env python
2) Change the mode of the script to 755
to make the script executable
sudo chmod 755 /app/nagios_install/backup/nagios_backup.py
3) Schedule the cron job from the root user's crontab
sudo crontab -e
crontab -e
opens up current user's crontab by default, and not root user's crontab. And the nagios
directory may not be acceessible by that current user.
4) Remove the SHELL
variable from your crontab, it isn't needed in the first place. You are not using variables LOGNAME
, HOME
either, so they can also be removed, I don't think they were needed either.
5) Schedule the cron job like following in your root user's crontab
17 12 * * * /app/nagios_install/backup/nagios_backup.py >> /var/log/nagios_backup.log 2>&1
I think the above setup should work. If it doesn't, try running the script directly and let me know what error(s) it throws.