0

2 つのコマンドを発行する crontab があり、次のように 2 つのコマンドの間にスリープ時間を追加したいと思います: (command1 ; sleep ; command2)。

これは可能ですか?どのようにフォーマットされていますか?

助けてください!!

4

2 に答える 2

0

The ``sixth'' field (the rest of the line) specifies the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. - the crontab(5) man page

Essentially you already have the right base form, like: cmd1 ; sleep 60 ; cmd2 Any command, even complicated commands with loops and other logic should work, although you should be careful about which environment variables you might be relying on.

It's useful to run job in the near future to email the output of "env" to yourself just to check ;-)

For more complex stuff, create a shell script and have the crontab refer to it, like:

42 0 * * * $HOME/bin/daemon/cron-tmp-preen

于 2012-09-06T17:09:06.433 に答える
0

有効なshellコマンドが連続していれば実行できます。すべてを 1 行にまとめてください。

于 2012-09-06T17:27:28.220 に答える