Skip to content

Instantly share code, notes, and snippets.

@mattscilipoti
Created August 18, 2009 14:09
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 mattscilipoti/169729 to your computer and use it in GitHub Desktop.
Save mattscilipoti/169729 to your computer and use it in GitHub Desktop.
script/runner and crontab
MAILTO=me@example.com
TIPS_ROOT=/home/user_name/projects/project1
# m h dom mon dow command
*/1 * * * * $TIPS_ROOT/script/local_runner.sh script/ping_em_all.rb log/ping.log
#!/bin/bash
# Used for running script/runner using cron.
# Changes to app root dir (TIPS_ROOT), before calling script.runner using relative path.
# Params: script log_file
#
# Usage:
# script/local_runner script/script_name log/log_file
#
# h2. To use with cron:
# $ crontab -e
# add entry:
# */20 * * * * $TIPS_ROOT/script/local_runner.sh script/ping_em_all.rb log/ping.log
#
function display_usage {
echo "Usage:"
echo " script/local_runner.sh relative/path/to/script relative/path/log_file"
echo "Example:"
echo " script/local_runner.sh script/ping_em_all.rb log/ping.log"
}
if [ -z "$TIPS_ROOT" ]; then
echo "TIPS_ROOT is required"
exit 1
fi
if [ -z "$1" ]; then
echo "Script is required:"
display_usage
exit 1
fi
if [ -z "$2" ]; then
echo "log_file is required:"
display_usage
exit 1
fi
cd $TIPS_ROOT
/usr/local/bin/ruby script/runner $1 >> $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment