Skip to content

Instantly share code, notes, and snippets.

@ismet55555
Last active January 27, 2023 14:42
Show Gist options
  • Save ismet55555/757da1d6f087a8f2d9e3a96893f5274d to your computer and use it in GitHub Desktop.
Save ismet55555/757da1d6f087a8f2d9e3a96893f5274d to your computer and use it in GitHub Desktop.
Cron Running Script and Logging
#############################################################################
#
# crontab can be edited using the following command:
# For root user: sudo crontab -e
# For current user: cronttab -e
# For specific user: sudo cronttab -e -u ismet
#
# To view all current crontab entries:
# For root user: sudo crontab -l
# For current user: cronttab -l
#
# NOTES:
# - Root user crontab will have root privelages
# - Cron will not run while the crontab file is open for editing
# - You may have to restart cron (but it should automatically pick up changes):
# sudo service cron reload
#
#############################################################################
# Alert notification contact email in case something fails
MAILTO="xxxxxxxx@xxxxxxx.com"
# Specify to use bash shell for all cron jobs
SHELL=/bin/bash
# Specify PATH variable for all cron jobs
# Note: Cron will only have very minimal enviroment variables
# To find the system's PATH variable: $ echo $PATH
PATH=/home/<YOUR LOCAL USERNAME>/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Scheduled job to run and output/append any cron notifications and standard out messages to a log file
# Format: [minute 0-59] [hour 0-23] [day 1-31] [month 1-12] [weekday 0-6] [your command or scrip location] >> [file to save output log messages]
# Note: This following job will run every day at 3:05am
5 3 * * * /home/<YOUR LOCAL USERNAME>/Documents/lvm_snapshot_remote_backup.sh >> /home/<YOUR LOCAL USERNAME>/Documents/backup_message_logs/backup_message_log.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment