I need to restart one of my services regularly, I tried to to put this into my crontab:
0 0 * * * systemctl --user restart bot
I found that it doesn't work, after a few days when I check the status of the service, the uptime of it is over 2 days. If I run the same command manually it works, i use the root user BTW, it's VPS with nothing important on it.
Why wouldn't this work? what could be the issue here?
If I check /var/log/syslog this is the only line that's related to this particular job:
Aug 30 08:09:01 ubuntu CRON[21197]: (root) CMD (systemctl --user restart bot &>/var/log/bot.log)
I edited the schedule a dozen times to let it run the next minute to see if it works. Lines above and below this are about other jobs which work without any problems.
grep -i cron /var/log/syslog
– Panki Aug 30 '19 at 08:30&>
in that command would not work, as described in a few other questions regarding this: How to redirect output to a file from within cron? and Why does redirection in crontab result in a zero byte file? for example. – Kusalananda Aug 30 '19 at 12:21&>
redirection. Just now I tried something else, I put the commond in a file, then put the/path/to/myfile.sh
into crontab. Now I'm getting mail that saysFailed to connect to bus: No such file or directory
– SparedWhisle Aug 30 '19 at 12:30Failed to connect to bus
. Someone reading this should not need to read all the comments to figure out what you have tried and what state this is at currently. – Kusalananda Aug 30 '19 at 13:38