Last active
April 26, 2016 17:37
-
-
Save hugsbrugs/1a3406a1267904c798ba to your computer and use it in GitHub Desktop.
Cron how to
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
# List cron tasks for user www-data | |
sudo crontab -u www-data -l | |
# Edit cron tasks for user www-data | |
sudo crontab -u www-data -e | |
# Backup current user crontab | |
crontab -l > cron-backup.txt | |
# Restore current user crontab | |
crontab cron-backup.txt | |
# Backup user www-data crontab | |
crontab -u www-data -l > www-data-crontab-backup.txt | |
# Restore user www-data crontab | |
crontab -u www-data www-data-crontab-backup.txt | |
# Backup all users crontab (Debian) | |
zip -r all-users-crontab-backup.zip /var/spool/cron/crontabs | |
# Cron job to schedule backup of all users crontab | |
0 1 * * * zip -r all-users-crontab-backup.zip /var/spool/cron/crontabs | |
# Restore all users crontab | |
mv /var/spool/cron/crontabs /var/spool/cron/crontabs.backup | |
unzip all-users-crontab-backup.zip | |
cp all-users-crontab-backup /var/spool/cron/crontabs | |
# Jobby Cron task example | |
* * * * * cd /var/www/website/cron && php jobby.php 1>> /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment