Hallo,
vielleicht kann mir ja jemand weiterhelfen. Ich habe ein script, welches mir unter bestimmten Umständen eine email schicken soll. Das script soll nun als Cronjob laufen. Als email programm verwende ich msmtp. Im terminal funktioniert folgendes command problemlos:
1 | /usr/bin/msmtp meine@emailadresse.com < /tmp/index.html |
Dieser Befehl wird auch im script aufgerufen und wenn ich das script manuell aufrufe, krieg ich meine mail. Allerdings nicht wenn cron das aufruft. Das script wird zwar ausgeführt, allerdings wird keine mail verschickt.
Die /etc/crontab sieht so aus (das script ist ganz unten)
# /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) 0 7 * * * root /usr/local/bin/updater.sh > /dev/null 2>&1 */3 * * * * root /home/XXX/script.tcl >> /home/XXX/.log
Selbst wenn ich jetzt das mail command in den cronjob bringe, bekomme ich keine mail und das log wird geschrieben, aber bleibt leer:
*/1 * * * * matze /usr/bin/msmtp meine@emailadresse.com < /tmp/index.html >> /home/XXX/mail.log
Wo liegt das Problem? Danke für die Hilfe.
Update Ich bekomme nun emails mit diesem croneintrag:
*/1 * * * * matze /usr/bin/msmtp meine@emailadresse.com < /tmp/index.html >> /home/XXX/mail.log
Allerdings passiert ueber das script immer noch nichts... Es ist ein tcl script, ich poste es mail hier:
#!/usr/bin/tclsh cd /tmp set ipsource "http://checkip.dyndns.org" if {[file exist index.html]} { exec rm index.html } puts "Downloading new IP from $ipsource..." exec -ignorestderr wget -nv $ipsource puts "Sending mail" exec /usr/bin/msmtp meine@mail.com < /tmp/index.html puts "Mail sent" exit