小编use*_*411的帖子

使用 cron 每分钟执行一个 shell

我想使用 cron 每分钟运行这个 bash 代码。我把它保存到/root/activate.sh

#!/bin/bash

for file in /home/user/torrents/*.torrent

do
if [ "$file" != "/home/user/torrents/*.torrent" ]; then
echo [`date`] "$file" added to queue. >> /var/log/torrentwatch.log
/usr/bin/transmission-remote localhost:9091 -a "$file"
mv "$file" "$file".added
sleep 1
fi
done
Run Code Online (Sandbox Code Playgroud)

权限已设置-rwxrwxrwx 1 root root 278 May 27 01:27 activate.sh

然后crontab -e我把这个放在里面

* * * * * root sh /root/activate.sh

该脚本不执行,我收到此日志错误

May 27 01:40:02 media CRON[3556]: (root) CMD (root sh /root/activate.sh)
May 27 01:40:02 media CRON[3555]: (CRON) info (No MTA …
Run Code Online (Sandbox Code Playgroud)

bash cron

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

bash ×1

cron ×1