Created
August 18, 2009 14:09
-
-
Save mattscilipoti/169729 to your computer and use it in GitHub Desktop.
script/runner and crontab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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