mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   GpuOwl (https://www.mersenneforum.org/forumdisplay.php?f=171)
-   -   Gpuowl / Linux question (https://www.mersenneforum.org/showthread.php?t=25065)

Prime95 2020-01-03 20:45

[QUOTE=paulunderwood;534072]If you can hack this not-so-great code...

[CODE]if (( $(date +%s) > $(stat -c %Y -- examplefile.txt ) + 3600 )); then killall gpuowl; echo "hi" ; fi;
[/CODE][/QUOTE]

I've got the gpuowl.log-not-being-updated part working (see below). Thanks.

[CODE]if (( $(date +%s) > $(stat -c %Y -- /home/george/gpuowl1/gpuowl.log) + 3600 ||
$(date +%s) > $(stat -c %Y -- /home/george/gpuowl2/gpuowl.log) + 3600 ||
$(date +%s) > $(stat -c %Y -- /home/george/gpuowl3/gpuowl.log) + 3600));
then
killall gpuowl;
sleep 30
# /root/gpu-settings
# /root/gpu-settings1
# /root/gpu-settings2
screen -S owl1 /home/george/gpuowl1/gpuowl -dir /home/george/gpuowl1
screen -S owl2 /home/george/gpuowl2/gpuowl -dir /home/george/gpuowl2
screen -S owl3 /home/george/gpuowl3/gpuowl -dir /home/george/gpuowl3
fi;[/CODE]

Is there a preferred way to run a sudo command from this script? I'd like to add this line to my crontab script "sudo /root/gpu-settings" without asking for a password.

paulunderwood 2020-01-03 22:06

[QUOTE=Prime95;534155]I've got the gpuowl.log-not-being-updated part working (see below). Thanks.

[CODE]if (( $(date +%s) > $(stat -c %Y -- /home/george/gpuowl1/gpuowl.log) + 3600 ||
$(date +%s) > $(stat -c %Y -- /home/george/gpuowl2/gpuowl.log) + 3600 ||
$(date +%s) > $(stat -c %Y -- /home/george/gpuowl3/gpuowl.log) + 3600));
then
killall gpuowl;
sleep 30
# /root/gpu-settings
# /root/gpu-settings1
# /root/gpu-settings2
screen -S owl1 /home/george/gpuowl1/gpuowl -dir /home/george/gpuowl1
screen -S owl2 /home/george/gpuowl2/gpuowl -dir /home/george/gpuowl2
screen -S owl3 /home/george/gpuowl3/gpuowl -dir /home/george/gpuowl3
fi;[/CODE]

Is there a preferred way to run a sudo command from this script? I'd like to add this line to my crontab script "sudo /root/gpu-settings" without asking for a password.[/QUOTE]

You could do this:

[CODE]echo "password" | sudo -S /root/gpu-settings[/CODE]

For security reasons you should use root's crontab

Prime95 2020-01-03 22:44

[QUOTE=paulunderwood;534169]You could do this:

[CODE]echo "password" | sudo -S /root/gpu-settings[/CODE]

For security reasons you should use root's crontab[/QUOTE]

It's a standalone machine in my house, so security isn't a real big concern.

I was unable to get root crontab to work with "@reboot". However, you are correct that this would be handled by root's crontab since it is not a @reboot item.

Thanks for the help.


All times are UTC. The time now is 22:25.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.