Skip to content

Instantly share code, notes, and snippets.

@unfo
Last active December 25, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unfo/6899859 to your computer and use it in GitHub Desktop.
Save unfo/6899859 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Safer way to edit cron so you don't mistakenly REMOVE the entire crontab
# with crontab -r when you meant to type crontab -e
# Also provides useful diff of your changes
ts=$(date +%s)
before=/tmp/`whoami`_crontab_before_$ts
after=/tmp/`whoami`_crontab_after_$ts
crontab -l > $before
crontab -e
crontab -l > $after
diff $before $after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment