linux - Cron 每分钟运行一次(在 bash 中运行但不在 cron 中运行)

标签 linux bash shell cron

这在之前的帖子中已经讨论过多次。我遵循了给出的建议,但它对我不起作用。我有两个脚本,每分钟由 cron 服务运行一次。令我惊讶的是,每分钟只运行一个(下面列表中的第一个),另一个失败(下面列表中的第二个)。最令人惊讶的是,当直接从终端运行时,两个脚本都可以正常执行。

Cron setup :
*/1  * * * * /home/user/Desktop/scripts/generatepattern.sh
*/1  * * * * /home/user/Desktop/scripts/getnextfile.sh

文件权限是:

-rwxr--r-- 1 user user 522 Jul 25 16:18 generatepattern.sh
-rwxr--r-- 1 user user 312 Jul 25 23:02 getnextfile.sh

不可调度(不在 cron 中运行)的代码是:

#!/bin/bash
#Generate a file to be used for the search
cd /home/user/Desktop/scripts
no=`cat  filecount.txt`
if test $no -lt 20
then
    #echo "echo less"
    #echo $no
    expr `cat filecount.txt` + 1 >filecount.txt
fi

最佳答案

在最后一行中,您编写了 cat filecount.txt 而不是 cat/home/user/Desktop/scripts/filecount.txt

关于linux - Cron 每分钟运行一次(在 bash 中运行但不在 cron 中运行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31631319/

相关文章:

php - 使用 PHP 和 Linux 处理特殊字符

linux - 递归地chmod

php - SSL_ERROR_PROTOCOL_VERSION_ALERT : Peer reports incompatible or unsupported protocol version

bash - 从 bash 中的管道读取时“读取”不会超时

linux - apt-get install 只显示最后一行

c - 使用 execl 获取 grep 值

linux - 如何在打开新终端时自动登录到ssh服务器

regex - 使用 sed 在附加文本之前追加两个新行

linux - 使用 sshpass 时如何转义单引号

python - 在 Shell 和 SQLAlchemy 中编辑 Python 类