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

Restart Nginx Nightly with Cron

To restart nginx every night at 3 AM, add one line to root's crontab. In almost every case you want reload (zero-downtime) rather than restart, so nginx picks up rotated logs or renewed certs without dropping connections.

The crontab line

Edit root's crontab with sudo crontab -e and add:

0 3 * * * /usr/bin/systemctl reload nginx

This reloads at 03:00 every day. Use the full path to systemctl because cron runs with a minimal PATH.

reload vs restart

reload re-reads the config and gracefully swaps workers with no dropped requests. restart stops and starts the master process, causing a brief outage. Only use restart if a module or the binary itself changed.

Log the outcome

0 3 * * * /usr/bin/systemctl reload nginx >> /var/log/nginx-reload.log 2>&1 keeps a record so you can confirm it ran and catch config errors.

FAQ

What cron schedule restarts nginx every night?

0 3 * * * /usr/bin/systemctl reload nginx runs at 3 AM daily. Change the hour field (3) to any hour you prefer.

Should I use reload or restart for nginx in cron?

Use reload — it swaps workers gracefully with zero downtime. Restart briefly stops nginx and drops connections; only needed when the binary or a module changed.

Why doesn't systemctl work in my crontab?

Cron uses a minimal PATH, so bare 'systemctl' may not resolve. Use the absolute path /usr/bin/systemctl (run 'which systemctl' to confirm the location).