A python script to shutdown system works fine from the terminal but doesn't work when included in crontab. The script is called by cron but ends with an error 'shutdown command not found'or 'init 0 command not found'. I am using fedora 17 and the script is executed from root's crontab.#!/usr/bin/pythonimport osos.system('shutdown')os.system('init 0')
Python script to shutdown system doesn't work in cron
cron;python
I guess the first line of your snippet is supposed to be something like:#!/usr/local/bin/pythonor, if you also make sure you set an appropriate value for PATH in your crontab:#!/bin/env pythonWhat does your crontab entry look like? Don't forget that cron sets a very limited environment, so you will need to provide the full path to the script file so that cron can find it.Additionally, python probably can't find shutdown when called from cron, because it will inherit cron's limited environment. Try providing the full path to the shutdown command in your os.system() call.