スコア
22
Advertisement
回答 (6)
スコア
38
2009-12-10 09:04:32 +0000
これはカーネルがどのコマンドインタプリタがスクリプトに使用されるかを示すために解釈する魔法です。
以下のようにしてください。
#!/bin/sh
notify-send "hi welcome"
のようにして、スクリプトが実行可能であることを確認してください。
ls -l home/hacks/notify.sh
chmod +x home/hacks/notify.sh
ls -l home/hacks/notify.sh
また、これを一日に一度だけ発生させたいとのことですが、crontabのタイムゾーンはあなたのタイムゾーンと同じですか?これはグリニッジ標準時の午後2時に発生しているかもしれません。
Advertisement
スコア
18
2010-03-25 06:05:09 +0000
crontabを動作させるのは簡単だが、ここではcrontabのジョブの動かし方を説明する。crontabに行き詰っている人には参考になると思います。
*/1 * * * * cd /home/hacks && sh notify.sh
chmod +x home/hacks/notify.sh
ここでは、このスクリプトを1分ごとに実行しています。以下のスクリプトを実行することで、ログファイルに書き込んで動作しているかどうかを確認することができます
ログの書き込み
*/1 * * * * cd /home/hacks && sh notify.sh>>test.log
メールの送信
*/1 * * * * cd /home/hacks && sh notify.sh>>test.log | mail -s "Hi this is example" user@domain.com
Advertisement
Advertisement
スコア
0
2015-10-24 12:00:18 +0000
まず、crontabをコマンドcrontab -eで編集し、このCrontabの中に実行スクリプトのパスを追加します。 * 14 * * * home/hacks/notify.sh >/dev/null 2>&1 .
Start /Stop / restart cron service
/etc/init.d/crond start /stop / restartservice crond start /stop /restartsystemctl stop crond.service
systemctl stop crond.service