Skip to content

Adding jobs to another users crontab

Brendon Muir edited this page Nov 25, 2015 · 1 revision

Sometimes you might like your tasks to run as a particular user on your system (different from your deploy user). For example you deploy with the deploy user but the web server runs as www-data and you want your tasks to run as that user so that your environment is as similar as possible to that in which your app runs (files are created with the correct permissions from within the task etc...). Here's how when using Capistrano 3:

Add this to your deploy.rb

set :whenever_command, ->{ [:bundle, :exec, :whenever, '--user www-data'] }

You can add additional command variables there too.