Im trying to use this rule to backup the system every week to USB media.
rule "Backup ready for USB, in the proceeding rule"
when
Time cron "0 0 1 ? * * *"
then
logInfo("Server Backup", "Server is being backed up")
executeCommandLine("sudo openhab-cli backup /home/kris/Backup.zip")
end
But, it keeps asking for a password when I execute the rule.
using sudo visudo I have:
openhab ALL=(ALL) NOPASSWD: ALL
But it still wants a password
Can anyone suggest what Iām doing wrong ? Thanks
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
2
Have you considered running this from a Crontab instead?
Iāll second the suggestion to use crontab. This is the sort of thing cron was created to do. And like Stuart says, you donāt need to give openhab permissions to do stuff it doesnāt need to do.
If you set up mail on your machine (I use msmpt) cron will send an email with the output from the command after it runs so you can keep track that it did in fact run.
This should execute every tuesday at 6:35 as user ārootā and will redirect every output (standard and error) to the log files.
edit: I would not put the two lines on the same minuteā¦you are not sure if the backup has finishedā¦give it some time. you also were missing a ā/ā in the second line to copy away the file
edit2: The log paths were wrong must be /var/log not /var/logs
Mmmmm okā¦thatās because you used crontab -e to edit di cron without being rootā¦so itās your userās cron, you cannot use the root user.
You can go two ways:
use sudo crontab -e to edit the root cron (this way you need to drop the root user from the line)
Manually edit the system crontab with sudo nano /etc/crontab (use your own text editorā¦I usually prefer vi ) this way you can leave those lines as they are.