dongtiran7769 2012-04-04 11:15
浏览 45
已采纳

如何使用crontab使用svn更新代码?

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 https://example.com/projectname/trunk/app app

Now I created update.sh file in /var/www/ with following content

cd /var/www/staging
rm -r app.old
mv app app.old
svn checkout https://example.com/projectname/trunk/app app

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

*/5 * * * * /var/www/update.sh

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/update.sh 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?

Thanks

  • 写回答

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://example.com/projectname/trunk/app app
    

    Next, change the line in your crontab to this:

    */5 * * * * /var/www/update.sh 2>&1| mail -s "Cron job execution" youremail@wherever.com
    

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目