Answer the question
In order to leave comments, you need to log in
Why doesn't the script run via crontab -e as a user?
Ubuntu Linux distribution 13.10
* * * * * agent /bin/bash /home/agent/rails_projects/project/rake_script.sh 2> /home/agent/errors
/bin/sh: 1: agent: not found
agent:x:1000:1000:agent,,,:/home/agent:/bin/bash
* * * * * agent sh /home/agent/rails_projects/project/rake_script.sh 2> /home/agent/errors
#!/bin/bash
cd /home/agent/rails_projects/project
bundle exec rake db:alarm
Answer the question
In order to leave comments, you need to log in
You cannot specify a user in a cron job. There can only be a command line. The word agent is interpreted as a command that does not exist.
Also, be prepared that when you run the script this way, the value of $PATH will be different from what you see in the interactive session, and you will need to additionally do . /etc/profile or . ~/.bash_profile.
You do not need to specify a user in crontab -e. Just
remove the space after 2>. If you are going to do it through -e, then add the user to /etc/cron.allow
Then do chmod +x /home/agent/rails_projects/project/rake_script.sh and write to cron like this:
# если в crontab -e, то
* * * * * /home/agent/rails_projects/project/rake_script.sh 2>home/agent/errors
# если в /etc/cron.d/sth или /etc/crontab, то
* * * * * agent /home/agent/rails_projects/project/rake_script.sh 2>home/agent/errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question