Mei 23, 2026Handleidingen
Cron-taken instellen op een Linux-server
Cron-syntaxis, crontab bewerken, veelvoorkomende voorbeelden en logging op de VPS.

Cron is de standaard planner op Linux voor scripts op vaste tijden: back-ups, cache legen, certificaatcontroles. Gids voor cron op uw Hiddence-server.
Cron-syntaxis
Elke regel heeft vijf tijdvelden en het commando:
bash
# ┌──────── minute (0-59)
# │ ┌────── hour (0-23)
# │ │ ┌──── day of month (1-31)
# │ │ │ ┌── month (1-12)
# │ │ │ │ ┌─ day of week (0-7, 0 and 7 = Sunday)
# │ │ │ │ │
# * * * * * command
# Every day at 3:00 AM:
0 3 * * * /usr/local/bin/backup.sh
# Every 15 minutes:
*/15 * * * * /usr/local/bin/check.shCrontab bewerken
crontab -e voor de huidige gebruiker. Systeemtaken via root:
bash
# Edit your user crontab
crontab -e
# Edit root crontab
sudo crontab -e
# List current jobs
crontab -l
sudo crontab -lVeelvoorkomende voorbeelden
- 0 2 * * * — dagelijkse back-up om 2:00
- 0 */6 * * * — elke 6 uur
- 0 0 * * 0 — elke zondag om middernacht
- */5 * * * * — elke 5 minuten (voorzichtig met belasting)
- @reboot /path/script.sh — na serverherstart
- @daily /usr/bin/certbot renew --quiet — dagelijkse SSL-vernieuwing
Logboeken en debuggen
Leid uitvoer naar een logbestand om fouten te zien:
bash
0 3 * * * /usr/local/bin/backup.sh >> /var/log/backup-cron.log 2>&1
# View cron execution in system log:
grep CRON /var/log/syslog # Ubuntu
grep CRON /var/log/cron # CentOSTips
- Gebruik absolute paden in cron-commando's
- Test scripts handmatig vóór toevoegen aan crontab
- MAILTO=email in crontab voor foutmeldingen
- Overweeg systemd timers voor complexe scenario's
- Voer geen zware taken elke minuut uit