Created
November 4, 2014 06:28
-
-
Save waifung0207/c2f58bb717cd85f8772e to your computer and use it in GitHub Desktop.
Server Cron Job Sample
This file contains 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
0 0 * * * /home/username/run_cron.sh |
This file contains 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
# 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