2

Is it possible to add cron command like "sudo systemctl restart exim4"? Usually in cronjob's list there's a path to the execution file, but looks like vestacp has list of other commands which is not included like "systemctl {action} {service}". Do I need to make some kind of file with mentioned command execution? Because I believe cronjob with command "sudo systemctl restart exim4" not going to work.

Ubuntu 18.04

Tom Dee
  • 23

1 Answers1

2

Well, sudo may require a tty, I believe it won't get a tty from cron. But if you can sudo then probably you can edit the system-wide crontab (/etc/crontab; or put a file in /etc/cron.d). This is a way to make cron restart a system-wide service, not with sudo from a user's crontab.

E.g. in /etc/crontab in my Debian I have put:

47 2    * * 2,6 root    systemctl restart transmission-daemon.service

to restart transmission twice a week (I have my reasons) and I know it works.

Note the system-wide crontab requires an extra field (root in the example above) and it's different than root's crontab.