Skip to content

Instantly share code, notes, and snippets.

@StevenMMortimer
Last active December 23, 2015 19:32
Show Gist options
  • Save StevenMMortimer/8e8c6954b8e4846b3d1a to your computer and use it in GitHub Desktop.
Save StevenMMortimer/8e8c6954b8e4846b3d1a to your computer and use it in GitHub Desktop.
# BELOW IS THE FORMAT OF A CRONTAB THAT WILL:
# EXECUTE AN R SCRIPT COMMAND, SEND STDERR AND STDOUT TO A TEMP FILE
# WHILE ONLY SENDING THE CONTENTS OF THE TEMP FILE TO SCREEN, WHICH TRIGGERS AN EMAIL,
# IF THE EXIT CODE OF THE RSCRIPT WAS NON-ZERO
# ESSENTIALLY CONFIGURATION LOGS EVERYTHING WHILE EMAILING ONLY ON ERROR
#
# To install a cron from this file use:
# dos2unix < mycrontab.txt | crontab -
# NOTE: mycrontab.txt must have everything needed since it completely wipes the existing crontab
#
# This means run every minute
# * * * * * command myscript
#
* * * * * Rscript myrscript.R > temp.log 2>&1 || cat temp.log && cat temp.log >> reallog.log && rm temp.log
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment