Skip to content

Instantly share code, notes, and snippets.

@hanvari
Last active February 12, 2021 07:02
Show Gist options
  • Save hanvari/58d151d38cce25a4a1ded337dd5a1cd0 to your computer and use it in GitHub Desktop.
Save hanvari/58d151d38cce25a4a1ded337dd5a1cd0 to your computer and use it in GitHub Desktop.
Creating Cronjob in cPanel

Cron-Job creation in cPanel

Command for Automated MySQL DB Backup

mysqldump --triggers --routines --events --tz-utc \
          -u<user> -p<pass> <db-name> | \ 
          gzip -9 > /full/path/to/backup/folder/`date +"\%Y-\%m-\%d-\%H\%M"`_my_db.sql.gz
  • The date format parameters must be escaped as %
  • If the command results in any output to STDOUT, an email will be sent with that response. Otherwise there is no email.

Command for Running a PHP Script

/usr/local/bin/php -f /home/username/public_html/folder/file.php > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment