Created
August 5, 2025 02:29
-
-
Save henri/b918454ff7ec91e31d9fd9aac8e446e3 to your computer and use it in GitHub Desktop.
crontab cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# (C)2020 Henri Shustak | |
# Released Under the MIT Licence | |
# https://mit-license.org/ | |
# | |
# dump the crontab | |
user_name=$(whoami) | |
host_name=$(hostname) | |
day=$(date +%w) | |
# test that varable HOME is in your path if you run this via crontab | |
cron_dump_dir="$HOME/backup-config/crontab" | |
# create the directory if it is not present | |
if ! [ -d $cron_dump_dir ] ; then mkdir -p $cron_dump_dir ; fi | |
# dump that crontab | |
cron_dump_file="${cron_dump_dir}/${host_name}-${user_name}-crontab-$day" | |
if [ -d "${cron_dump_dir}" ] ; then | |
crontab -l > "${cron_dump_file}" | |
else | |
echo "cron_dump_dir not avaialble : ${cron_dump_dir}" | |
exit -99 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment