Hi,

monit execute the script directly, it doesn’t run it using shell - if you need 
I/O redirection, backticks, pipes, etc., you need to wrap it the same way the 
stop command is wrapped:

       start program = “/bin/bash -c ‘/home/ubuntu/xyz.py &> 
/home/ubuntu/logs/xyz_`date +\%m_\%d_\%y_\%H_\%M_\%S`.log'”

Regards,
Martin


> On 21 Nov 2014, at 07:11, Arzav Jain <[email protected]> wrote:
> 
> Hi there!
> 
> I'm using the following check syntax to run a python script continuously and 
> redirect the output of the script to a log file:
> 
> check process xyz with pidfile /tmp/xyz.pid
>        start program = "/home/ubuntu/xyz.py &> /home/ubuntu/logs/xyz_`date 
> +\%m_\%d_\%y_\%H_\%M_\%S`.log"
>        stop program = "/bin/bash -c 'kill -s SIGTERM `cat /tmp/xyz.pid`'"
>        if changed pid then restart
>        if changed pid then alert
> 
> However, when I look at the monit logfile, only /home/ubuntu/xyz.py is 
> executed as part of the start command and the redirection is missing. I 
> confirmed this by verifying that the log file is missing in the 
> /home/ubuntu/logs directory.
> 
> Can someone please tell me how to redirect stdout of the script to a file so 
> that I may see what errors crashed the script? If not, what is the best way 
> to know why my script crashed and needed to be restarted?
> 
> Thanks a lot!
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to