Skip to content

Instantly share code, notes, and snippets.

@erhangundogan
Last active July 5, 2025 16:46
Show Gist options
  • Save erhangundogan/37a64d54c3dee3be9af9051b54e21444 to your computer and use it in GitHub Desktop.
Save erhangundogan/37a64d54c3dee3be9af9051b54e21444 to your computer and use it in GitHub Desktop.
Alpine CronJobs

crond/crontabs

setup

# change root for other users
$ vi /etc/crontabs/root
# for example add /etc/periodic/minute folder below to run every minute

# do daily/weekly/monthly maintenance
# min   hour    day     month   weekday command
*       *       *       *       *       run-parts /etc/periodic/minute
*/15    *       *       *       *       run-parts /etc/periodic/15min
0       *       *       *       *       run-parts /etc/periodic/hourly
0       2       *       *       *       run-parts /etc/periodic/daily
0       3       *       *       6       run-parts /etc/periodic/weekly
0       5       1       *       *       run-parts /etc/periodic/monthly
# you may need this after /etc/crontabs/root changes
$ rc-service crond restart
$ cat <<EOF > /etc/periodic/minute/print_date
#!/bin/sh
date > /root/current_date
EOF
$ chmod +x /etc/periodic/minute/print_date

test

$ cd
$ cat current_date
Sat Jul  5 16:45:00 UTC 2025
# to run cron jobs from particular folder
run-parts /etc/periodic/minute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment