Skip to content

Instantly share code, notes, and snippets.

@waifung0207
Created November 4, 2014 06:28
Show Gist options
  • Save waifung0207/c2f58bb717cd85f8772e to your computer and use it in GitHub Desktop.
Save waifung0207/c2f58bb717cd85f8772e to your computer and use it in GitHub Desktop.
Server Cron Job Sample
0 0 * * * /home/username/run_cron.sh
# Get date of today
_now=$(date +"%m_%d_%Y")
# Sample 1: backup MySQL database
_file="/home/username/backup/db_$_now.sql"
mysqldump -u root -p'password' db_name > "$_file"
# Sample 2: calling web request (e.g. invoke API)
_url="http://localhost/website/daily_cron"
_file="/home/username/log/cron_$now.txt"
wget "$_url" -O "$_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment