crontab 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # desktop reminders
  2. # as normal user (not root): crontab -e
  3. #
  4. # m h dom mon dow command -i icon "subject" (no timeout/click to remove) "concise message"
  5. #
  6. # icon directories:
  7. # /usr/share/icons or ~/.local/share/icons (filename without extension)
  8. #
  9. # export variables are necessary as the crontab runs headless in the background with no display utility
  10. DISPLAY=":0.0"
  11. XAUTHORITY="/home/angela/.Xauthority"
  12. # full path to your .Xauthority file
  13. XDG_RUNTIME_DIR="/run/user/1000"
  14. # if your user id is not 1000, find via cli by: id -u
  15. 00 19 26 * * notify-send -i gnome-warning "Reminder" -u critical "message body"
  16. 05 19 11 * * notify-send -i gnome-warning "Reminder" -u critical "message body"
  17. 10 19 22-28 * 5 notify-send -i calligraplan "Reminder" -u critical "message body"
  18. 15 19 */15 * * notify-send -i kchart "Reminder" -u critical "message body"
  19. 50 23 30 * * notify-send -i gnome-warning "Reminder" -u critical "message body"
  20. # a warning to turn off the vpn, else the pull will fail w/ ip filtering in place
  21. 30 15 * * 0 notify-send -i gnome-warning "Turn off VPN" -u critical "DB Backup is about to commence, in 5 minutes"
  22. # pull db backups from a remote server (using git) and notify me when done, on sunday
  23. # pipes the output response to a variable and reads it back in the notification bubble via $GITOUTPUT
  24. # if the connection fails, the output hangs!!
  25. # chmod +x /home/your_user/.config/db-backup-cron.sh else it will fail
  26. 35 15 * * 0 35 15 * * * ~/.config/db-backup-cron.sh
  27. ### remote crons ###
  28. # this will run a dump of *all* databases and append them to a single file, bzip them for max compression
  29. # if you have insanely large databases you may want to trim obsolete records; bzip has great compression, but is also slow
  30. # absolute paths for system executables may/may not be necessary, depending on your system; nowadays probably not
  31. # --defaults-extra-file usage prevents using mysql passwords on cli & storing in a non-public system directory
  32. cd /home/user/hiddenpath/ && /usr/bin/mysqldump --defaults-extra-file=/home/user/sql.cnf --opt --all-databases --ignore-database=information_schema --ignore-database=mysql --ignore-database=performance_schema --ignore-database=phpmyadmin | bzip2 > /home/user/hiddenpath/sqlbackup-`date +\%Y\%m\%d`.sql.bz2 && git add . && git commit -m "Backup" && cd > /dev/null 2>&1
  33. # rotate database backups older than 5 days, automate git commit so my local cron can login via ssh (pk auth) and do a pull without manual intervention
  34. # only remove files with the sqlbackup-*.sql.bz2 filename, to prevent removal for the .git folder
  35. cd /home/user/hiddenpath/ && /usr/bin/find /home/user/hiddenpath/* -name "sqlbackup-*.sql.bz2" -mtime +5 -exec rm {} \; && git add . && git commit -m "Purge old backups" && cd > /dev/null 2>&1
  36. # > /dev/null 2>&1 = redirect stdout/stderr to a blackhole (no email notifications)