適切な設定後も Cron ジョブが実行されない

適切な設定後も Cron ジョブが実行されない

そこで、以下に示すように cron ジョブを作成しました。

  GNU nano 2.2.6                    File: /tmp/crontab.uNoEXy/crontab

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/3 *  *    *   *    /home/kyle/runBackup.sh

これはテスト用で、指定されたとおりに 3 分ごとにスクリプトを実行します。はい、確認したところvar/log/syslog、今日の cron は実行されていません。この cron の実行の証拠は、.tar.gz私の Dropbox フォルダにあるファイルです。これは、スクリプトを自分で実行すると発生します。何も起こらないのは、それを cron に入れることだけです。

答え1

次を試してください:

*/3 * * * * /home/kyle/runBackup.sh

CRON式は5つ以上の空白で区切られた6つのフィールド

詳細については以下を参照してください。http://en.wikipedia.org/wiki/クロン

答え2

私も非常に似たような問題を抱えていましたが、ジョブの実行がスケジュールされた後、ルートのメールが /var/spool/mail に配置されていること、つまり、ジョブが配置されたのはルート crontab であり、ルート ユーザーにジョブを実行する権限がないことが示されていたことに気付きました。調べてみたところ、ターゲット スクリプトが実行可能ではないことが原因であることがわかりました。次の操作を実行した場合:

ls -la /home/kyle/

runBackup.sh に -rw-r--r-- 権限が表示される場合は、次を試してください。

chmod +x /home/kyle/runBackup.sh

これにより、権限が -rwxr-xr-x になり、ジョブの実行が許可されます。

ソースマテリアル

関連情報