2012-04-04 11:15
浏览 39


I am using following steps to update code on server after login to server:

sudo -s
<wrote password here>
cd /var/www/staging
rm -r app.old
mv app app.old
svn checkout app

Now I created file in /var/www/ with following content

cd /var/www/staging
rm -r app.old
mv app app.old
svn checkout app

And I have following crontab entry to run after every 5 minutes:

*/5 * * * * /var/www/

Problem: So cron job is working but it is only deleting the app folder and not checking out it from svn repository. But when I run bash /var/www/ manually it works fine after sudo -s.

How to fix this for cron job as well. Is it related to sudo -s or something else?


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpq59734 2012-04-04 12:01

    I suspect the problem is that the job is running from cron as root and root user doesn't have permissions to checkout.

    First, I suggest that you include details of the username/password to use with SVN - inside your script:

    svn checkout --username USER --password PASS ttps:// app

    Next, change the line in your crontab to this:

    */5 * * * * /var/www/ 2>&1| mail -s "Cron job execution"

    Then, when the job executes, any errors would be sent to you via email. At least you'll see what is going wrong.

    打赏 评论
  • doubu5154 2012-04-04 11:28

    If you need to run it as a different user, then install it on that users crontab. Rather than trying to sudo over in the script.

    打赏 评论

相关推荐 更多相似问题