From 08a0445db78d4b522c4eeaf8550ce2fcb23dd0cb Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Mon, 5 Sep 2022 12:44:49 +0200 Subject: [PATCH] Added crontab's notes to the KB --- knowledge base/crontab.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 knowledge base/crontab.md diff --git a/knowledge base/crontab.md b/knowledge base/crontab.md new file mode 100644 index 0000000..7e4176b --- /dev/null +++ b/knowledge base/crontab.md @@ -0,0 +1,38 @@ +# Crontab + +## TL;DR + +```sh +# List existing jobs. +crontab -l +sudo crontab -l -u other_user + +# Edit crontab files. +crontab -e +sudo crontab -e -u other_user + +# Replace the current crontab with the contents of a given file. +crontab path/to/file +sudo crontab -u other_user path/to/file + +# Remove all cron jobs. +crontab -r +sudo crontab -r -u other_user +``` + +```text +# Run 'pwd' every day at 10PM. +0 22 * * * pwd + +# Run 'ls' every 10 minutes. +*/10 * * * * ls + +# Run a script at 02:34 every Friday. +34 2 * * Fri /absolute/path/to/script.sh +``` + +## Sources + +- [cheat.sh] + +[cheat.sh]: https://cheat.sh/crontab