From 68fea6a8dcd6d3ff59ae6ffe9f62f1903709441d Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Mon, 23 May 2022 19:30:04 +0100 Subject: [PATCH] Last Sync: 2022-05-23 19:30:04 --- Programming_Languages/Shell_Scripting/Cron.md | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Programming_Languages/Shell_Scripting/Cron.md b/Programming_Languages/Shell_Scripting/Cron.md index 8b6e69f..c95bd20 100644 --- a/Programming_Languages/Shell_Scripting/Cron.md +++ b/Programming_Languages/Shell_Scripting/Cron.md @@ -4,27 +4,35 @@ tags: - shell - automation --- -j +# Cron In Arch Linux I use `cronie` for cron jobs. (There is no cron service installed by default). +## Commands -````bash - -# View list of cron jobs +### List cron jobs +``` crontab -l +``` -# Open cron file +### Open cron file +``` crontab -e -```` +``` +### Check cron log +```bash -\*\*Syntax ** +journalctl | grep CRON +# Different distros have different loggers +``` +## Syntax ````bash m h d mon dow command # minute, hour, day of month, day of week, bash script/args # 0-59, 0-23, 1-31, 1-12, 0-6 ```` + **Examples** Run on the hour every hour @@ -39,6 +47,12 @@ At 01:42 every day: 42 1 * * * mysqlcheck --all-databases --check-only-changed --silent ```` +Every half hour: +``` +0,30 * * * * ${HOME}/bash_scripts/automate_commit.sh + +``` + **Shorthands** * `@reboot` – Run once, at startup