Skip to content

Instantly share code, notes, and snippets.

@czj
Last active January 15, 2017 18:22
Show Gist options
  • Save czj/e0d9397fe85ab51cbcd18b2a20330b8d to your computer and use it in GitHub Desktop.
Save czj/e0d9397fe85ab51cbcd18b2a20330b8d to your computer and use it in GitHub Desktop.
Running Rails 5.0.1 rake tasks without depreciation messages in cron
# This triple redirection allows filtering STDERR by removing depreciation messages
# The second grep allows removing empty lines (which might trigger an email on some server)
cd /home/appname/www/current && (RAILS_ENV=production bundle exec rake myapp:mytask 3>&1 1>&2 2>&3 | grep -v 'is deprecated' ) 3>&1 1>&2 2>&3 | grep -v ''
# You can also log STDOUT to a log file
cd /home/appname/www/current && ((RAILS_ENV=production bundle exec rake myapp:mytask 3>&1 1>&2 2>&3 | grep -v 'is deprecated' ) 3>&1 1>&2 2>&3 | grep -v '') >> /home/appname/www/shared/log/taskoutput.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment