#症状
cronで動くpythonスクリプトと動かないpythonスクリプトがでてしまいます(;;)
どなたか助けてくださると助かります;;
#環境
・ラズベリーパイ2(OS:Raspbian)
・python2.7
・$python hoge.pyと実行してコード自体の動作がきちんとしていることは確認済み
#経緯
pythonスクリプト hoge1.py ~ hoeg10.pyというコードをつくってcronに以下のように設定しました。
$sudo crontab -l # 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 00 18 * * 3 python /home/<ユーザー名です>/public_html/cgi-bin/hoge1.py 00 18 * * 4 python /home/<ユーザー名です>/public_html/cgi-bin/hoge2.py 00 18 * * 5 python /home/<ユーザー名です>/public_html/cgi-bin/hoge3.py 00 18 * * 6 python /home/<ユーザー名です>/public_html/cgi-bin/hoge4.py 00 9 * * 3 python /home/<ユーザー名です>/public_html/cgi-bin/hoge5.py 00 9 * * 4 python /home/<ユーザー名です>/public_html/cgi-bin/hoge6.py 00 9 * * 5 python /home/<ユーザー名です>/public_html/cgi-bin/hoge7.py 00 23 * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge8.py */30 * * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge9.py */10 * * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge10.py
その結果動くものと動かないものに分かれてしまいます 内訳は以下です
00 18 * * 3 python /home/<ユーザー名です>/public_html/cgi-bin/hoge1.py #動きます 00 18 * * 4 python /home/<ユーザー名です>/public_html/cgi-bin/hoge2.py #動きます 00 18 * * 5 python /home/<ユーザー名です>/public_html/cgi-bin/hoge3.py #動きます 00 18 * * 6 python /home/<ユーザー名です>/public_html/cgi-bin/hoge4.py #動きます 00 9 * * 3 python /home/<ユーザー名です>/public_html/cgi-bin/hoge5.py #動きます 00 9 * * 4 python /home/<ユーザー名です>/public_html/cgi-bin/hoge6.py #動きます 00 9 * * 5 python /home/<ユーザー名です>/public_html/cgi-bin/hoge7.py #動きます 00 23 * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge8.py #動きません */30 * * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge9.py #動きます */10 * * * * python /home/<ユーザー名です>/public_html/cgi-bin/hoge10.py #動きません
色々調べて、表記もチェックし、再起動しましたが、
($ sudo /etc/init.d/cron restart
[ ok ] Restarting cron (via systemctl): cron.service.)
となりましたが、症状は特に変化ありません。
ちなみにログ(var/log/syslog)を見ると、以下のようでした。MTAというものが関係しているのかな・・・とちょっと思いましたが、調べてみるとメール関係のモジュールのようで、自分のスクリプトはツイッターにツイートするものなので、ちょっと違うのかな。。。とおもったのですが・・・
Aug 19 12:30:01 raspberrypi CRON[23057]: (root) CMD (python /home/<ユーザー名です>/public_html/cgi-bin/hoge9.py)#実行されました Aug 19 12:30:01 raspberrypi CRON[23060]: (root) CMD (python /home/<ユーザー名です>/public_html/cgi-bin/hoge10.py)#実行されませんでした Aug 19 12:30:02 raspberrypi CRON[23049]: (CRON) info (No MTA installed, discarding output) Aug 19 12:30:04 raspberrypi CRON[23050]: (CRON) info (No MTA installed, discarding output)
以上です。もし解決法が分かる方がいらっしゃれば ぜひ教えてください。助かります(;;)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。