首页 > 解决方案 > Sh script not running using cron while running using terminal manually

问题描述

I have a script .sh that works when executed manually but not working through cron :

#!/bin/sh
sudo find . -name "*.log" -delete

There are other .sh which runs perfectly with cron.

I don't know why this one doesn't work.

I compared the env output from the terminal and from cron and both are similar beside the user which has higher privilege in cron using :

echo env > output.txt

The only difference between this script and others which work is the location of the file.

If anyone had a similar problem or know how to get more precise logs.

Thank you in advance

标签: linuxshellcron

解决方案


正如@Shawn 和@user1834428 在评论中提到的“。” 在我的脚本中没有指向我想要的地方。


推荐阅读