Ubuntu Hardy 上的 Cron 作业执行但未按预期删除文件
我在这里有点困惑,想知道是否有人可以给我一些指示:
我有一个 cron 作业,每天为特定用户执行,并且应该扫描特定目录中的文件。 从技术上讲,这是两份工作。 我已经打开 cron.log 来验证它们是否确实在执行,它们是:
May 24 11:03:01 AppNameGoesHere /USR/SBIN/CRON[11257]: (mongrel_AppNameGoesHere)
CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
{popular,index,purchasing,purchasing-alternate,support,about-us,guarantee,screenshots}.htm{,l})
May 24 11:04:01 AppNameGoesHere /USR/SBIN/CRON[11260]: (mongrel_AppNameGoesHere)
CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
{stats,popular,bcf,articles,expenses})
我已经删除了实际的用户名并对其进行了格式化,以便它在 StackOverflow 上不那么难看。
现在,我的问题是:尽管我可以在日志中看到这些删除正在执行并且显然成功,但如果我转到指定的目录,文件仍然存在。 我最初怀疑权限 hijinx 正在发生,但我已经验证我可以通过 su-ing 进入 mongrel_AppNameGoesHere 用户并发出单独的 rm 命令或通过将 cron 作业复制/粘贴到命令行来手动删除文件。 尽管该 cron 作业成功执行了几天,但我未手动执行的任何操作都会保持未执行状态。
对可能发生的事情有什么建议吗? 我之前直接在 /etc/crontab 文件中使用 Dapper Drake 和这些 cron 作业,当我升级到 Hardy 时,我将它们移动到特定于用户的 crontab(通过 sudo crontab -e - u mongrel_AppNameGoesHere) ,这就是他们似乎停止工作的点。)
I have a bit of a pickle here and wonder if anyone can give me some pointers:
I have a cron job which executes for a particular user daily and is supposed to sweep files in a particular directory. Technically, it is two jobs. I've turned on cron.log to verify they're actually executing, and they are:
May 24 11:03:01 AppNameGoesHere /USR/SBIN/CRON[11257]: (mongrel_AppNameGoesHere)
CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
{popular,index,purchasing,purchasing-alternate,support,about-us,guarantee,screenshots}.htm{,l})
May 24 11:04:01 AppNameGoesHere /USR/SBIN/CRON[11260]: (mongrel_AppNameGoesHere)
CMD (rm -rf /var/www/apps/AppNameGoesHere/current/public/
{stats,popular,bcf,articles,expenses})
I have removed the actual usernames and formatted it so that it is less ugly on StackOverflow.
Now, my question: Despite the fact that I can see these deletions executing and apparently succeeding in the log, if I go to the specified directory, the files are still there. I initially suspected permission hijinx were going on, but I've verified that I can delete the files manually by su-ing into the mongrel_AppNameGoesHere user and issuing individual rm commands or by copy/pasting the cron job to the command line. Anything that I don't manually zap stays unzapped despite days of that cron job executing successfully.
Any suggestions on to what might be happening? I was previously using Dapper Drake with these cron jobs in the /etc/crontab file directly, and when I upgraded to Hardy I moved them to user-specific crontabs (via sudo crontab -e - u mongrel_AppNameGoesHere
), which was the point where they appear to have stopped working.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 {} 是 shell 提供的 shell 扩展的一部分,因此为了使其工作,您需要更改执行 cron 条目的 shell。
默认情况下使用 /bin/sh,因此只需将:
SHELL=/bin/bash
作为 crontab 中的第一行,这样事情就应该再次开始工作。
Problem is the {} is part of shell expanding provided by the shell, so in order to make that work, you need to change the shell that executes the cron entries.
By default /bin/sh is used so just put:
SHELL=/bin/bash
as a first row in your crontab so things should start working again.