【发布时间】:2016-12-27 15:36:57
【问题描述】:
我想让我的 cron 命令从自定义 shell 执行如下:
SHELL=/bin/cron-launcher.sh
* * * * * test echo "toto" >> /tmp/shell.log
问题是如果我指定自己的 shell,文件 /tmp/shell.log 是空的。
我的自定义shell的内容如下:
#!/bin/bash -e
#Script use to launch cron tasks
set -e
SHELL="/bin/bash -e"
LOGDIR="/var/log/cronlauncher/"
echo "$USER" > /tmp/test.log
用于启动 cron 的用户很好地输出到文件 /tmp/test.log,但来自 cron 的 cron 命令 echo "toto" 永远不会输出到文件 /tmp/shell.log。
如何让自定义shell正确执行cron命令。
即让cron-launcher.sh脚本充当包装器。
以下是我的 /var/log/cron 的摘录:
12 月 26 日 15:55:01 bf7fe8653ac9 CROND[658]: (test) CMD ( echo "toto" >> /tmp/shell。
【问题讨论】:
-
cron-launcher.sh不是 shell,它是一个 bash 脚本。 -
确实如此,但我想让它像 shell 一样“行动”
-
或者更简单地充当外壳之间的包装器
-
1) 什么是
test? 2)/bin/cron-launcher.sh是否列在/etc/shells中? -
1)
test是用户测试 2) 不,它没有在/etc/shells中列出