initramfs / busybox cron (Ubuntu 18.04)
Note: full busybox installation is needed:
https://www.ullright.org/ullWiki/show/install-full-busybox-in-initramfs-ubuntu-18-04
- mkdir -p /var/spool/cron/crontabs
- busybox2 crontab -e
-
SHELL=/bin/bash */2 * * * *date >> /date.txt
-
- mkdir -p /var/log/
- busybox2 crond --help
-
BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.2) multi-call binary. Usage: crond -fbS -l N -L LOGFILE -c DIR -f Foreground -b Background (default) -S Log to syslog (default) -l N Set log level. Most verbose 0, default 8 -L FILE Log to FILE -c DIR Cron dir. Default:/var/spool/cron/crontabs
-
- busybox2 crond -L /var/log/crond.log
- ps | grep crond
- 352 root 2320 S busybox2 crond --L /var/log/crond.log
- busybox2 killall busybox2
- -> cron killed
- restart cron:
- busybox2 killall busybox2; busybox2 crond -L /var/log/crond.log
- show log:
- tail -f -n 100 /var/log/crond.log
Hints
- To log cron output redirect to stderr: date >&2
- To log to vga terminal: date > /dev/tty0
- To log to both: date | tee /dev/tty0 >&2