B
bmandl
Guest
Hello everybody.
I recently set up my raspberry pi with raspbian which is debian in general and I am accessing it throu VNC over LAN. I found a script and modified it a little, which checks if process is running and if not, it starts it and send me an email with ssmtp, so I now, that application restarted. I added the script to cron to run every 5 minutes. It is all working, but now, I would like to also send date and time, when application restarted. I am including my text for email with < command which is writen in txt file. If I add variables in this txt file, it doesn't convert them, they are just raw text. How could I include variable in ssmtp command?
This is my script:
I recently set up my raspberry pi with raspbian which is debian in general and I am accessing it throu VNC over LAN. I found a script and modified it a little, which checks if process is running and if not, it starts it and send me an email with ssmtp, so I now, that application restarted. I added the script to cron to run every 5 minutes. It is all working, but now, I would like to also send date and time, when application restarted. I am including my text for email with < command which is writen in txt file. If I add variables in this txt file, it doesn't convert them, they are just raw text. How could I include variable in ssmtp command?
This is my script:
Code:
#!/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
NOW=$(date +%c)
check_process() {
echo "$ts: checking $1"
[ "$1" = "" ] && return 0
[ `pgrep -n $1` ] && return 1 || return 0
}
# timestamp
ts=`date +%T`
echo "$ts: begin checking..."
check_process "myapplication"
[ $? -eq 0 ] && echo "$ts: not running, restarting..." && `env DISPLAY=:0.0 /usr/bin/myapplication > /dev/null`&& `ssmtp mymail < /home/pi/mail.txt`