Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active July 7, 2017 00:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nepsilon/9890593bddacfb1504702620a8caac47 to your computer and use it in GitHub Desktop.
Save nepsilon/9890593bddacfb1504702620a8caac47 to your computer and use it in GitHub Desktop.
Better using Crontab — First published in fullweb.io issue #42

Better using Crontab

Here are a few tips to get more out of Cron:

  • Test your scripts using Cron limited environment
  • Have it send you report to another email than root@locahost
  • Make it use another shell.
# Cron only provides a limited environment.
# To simulate it to test run your scripts
# first add this to your cron:
* * * * * env > ~/cronenv
# This will export the limited cron environment to a file.
# Now launch a new shell using this file to test your scripts:
$ env - `cat ~/cronenv` /bin/sh 

# Tell it what email to send output to:
# (You need to install Postfix locally before)
# In cron:
EMAIL=you@domain.com 

# You can also tell it what
# shell to use with:
SHELL=/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment