I'm trying to automatically run a script once every minute. But it might take more than 1 minutes sometimes & hence I have to have a lock on the script while it is running so that only one instance of the script can run at any given time.
My cronjob is as follows,
* * * * * root /usr/bin/flock -w 0 /var/cron.lock /pythonScripts/readPushData.py
My python script is set an executable using,
chmod a+x readPushData.py
The python compiler is set at the top of the script like,
The script can be run manually using './readPushData.py', but when I try to run it using a cronjob it doesn't work. Why is this happenning?
cronwill only run proper commands. Have you tried running
root /usr/bin/flock -w 0 /var/cron.lock /pythonScripts/readPushData.py?