crontool
Paste a schedule, read it in English, see the next runs.

Restarting a systemd Service with Cron

Use systemctl restart in a root crontab to restart a service on schedule. Give the full path /bin/systemctl because cron's PATH is minimal. For system-level scheduling, a systemd timer is often the more native choice.

The crontab line (root)

sudo crontab -e, then:

0 4 * * * /bin/systemctl restart myapp.service

Restarting a service needs root, so put this in root's crontab, not a user one.

Non-root user with sudo

Grant a NOPASSWD sudoers rule for the specific command, then:

0 4 * * * /usr/bin/sudo /bin/systemctl restart myapp.service

Consider a systemd timer instead

For restarting services, a .timer unit integrates with journald logging and dependency ordering. Cron is fine, but a timer is the more native path on systemd hosts.

FAQ

How do I restart a service with cron?

In root's crontab: 0 4 * * * /bin/systemctl restart myapp.service. Use the full path to systemctl.

Can a non-root user restart a service from cron?

Yes, with a NOPASSWD sudoers rule for that exact systemctl command, then call sudo systemctl restart in the crontab.

Cron or systemd timer to restart a service?

Both work. A systemd timer is more native on systemd hosts and logs to journald, but cron is perfectly fine for a simple restart.