インタプリタ ディレクティブの前の行 (行の前#!
) は間違っていますが、問題ではない可能性があります。は#!
、実行可能ファイルの最初の 2 文字としてのみ特別であり、どのプログラムで開く必要があるかを識別します (/bin/bash
この場合)。シェルは、デフォルトでスクリプトを解釈しようとする傾向がありますが、これは信頼できません。特に、sh 以外のスクリプトの場合はそうです。
次に、http://www.talisman.org/~erlkonig/documents/commandname-extensions-considered-harmful
だから/custom/update
#!/bin/bash
# update
/usr/bin/freshclam
maldet -b -a /home
次に実行します:chmod +x /custom/update
で./doandmail
:
#!/bin/bash
# doandmail
SUBJECT="Shell Script" # these don't need to be uppercase
EMAIL="myemail@gmail.com" # ...though it doesn't hurt anything
EMAILMESSAGE="mail.txt" # usually only exported variable are upper.
/custom/update | /bin/mail -s "$SUBJECT" "$EMAIL" # no need for a tmp file.
それで:chmod +x doandmail
実行するcrontab
と、明示的に設定しない限り、考えているのと同じディレクトリ、または期待するのと同じ環境さえありません。./update
の... 行で壊れている可能性が最も高いdoandmail
です。したがって、/custom/update
上記。
あなたのcrontabで:
@hourly /custom/doandmail