If script not running, execute the script (testpython.py)..
But unfortunately, it does not work. Any idea why? Did i miss something. Please advise. Thanks
Code: Select all
*/5 * * * * pgrep -f testpython.py || sudo python /home/pi/testpython.py
Code: Select all
*/5 * * * * pgrep -f testpython.py || sudo python /home/pi/testpython.py
Yes. able to.SonOfAMotherlessGoat wrote:Is the account this cron job runs under able to sudo without a password?
Add a cron file in /etc/cron.d, if you have php5 installed there's an example file in there.syscharger wrote:Is there alternative solution? If not using crontab.
Thanks
Code: Select all
#!/bin/bash
until (/home/pi/thingtokeepgettingrestartedwhenitdies.py);
do
sleep 30m # wait half an hour and give it another go.
done;
Code: Select all
Defaults:rj !requiretty
Nope.alexeames wrote:don't you need to include the full path to python in your cron job?
Yes, but this isn't one of them.cron can be exceedingly fussy
Code: Select all
#!/bin/sh
while [ 1 ]
do
/home/pi/blablayourpythoncommand.py or whatever
sleep 10
done
Code: Select all
[Unit]
Description=Private Pie server
[Service]
ExecStart=/usr/bin/python3 /home/pi/testpython.py
User=pi
Restart=always
RestartSec=360
StartLimitInterval=720
StartLimitBurst=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=PrivEye
[Install]
WantedBy=multi-user.target