did someone use crontab on juniper swith EX series? I would like to do restart httpd job, because I need to run this process with different config. I create some simple script with logging.
#!/bin/csh
echo 'Go...'
cp /jail/var/etc/httpd.conf_new /jail/var/etc/httpd.conf
echo 'changed'
set http_pid=`ps aux | grep 'httpd --config' | grep -v grep | awk '{print $2}'`
echo 'Process PID: ' "$http_pid"
kill -9 "$http_pid"
Also I create a job in crontab
10 12 * * * csh /var/root/test.sh >> test.log
When I run proces from cmd then output is:
Go...
changed
Process PID: 3158
And everything is ok but when I run it from cron then it looks like that:
Go...
changed
Process PID:
I try to change(add) to the crontab line with:
SHELL=/bin/csh
PATH=...
but didn't work. Also I try to change line with job to something like below:
10 12 * * * /var/root/.profile; csh /var/root/test.sh >> test.log
10 12 * * * sh /var/root/.profile; csh /var/root/test.sh >> test.log
10 12 * * * (sh /var/root/.profile; csh /var/root/test.sh) >> test.log
Maybe you know what can I do more to run this correctly?
I resolved this over the weekend. When the script is run via
crontab
using@reboot
, the script runs beforehttpd
is running, therefore there is no PID. I put asleep 60
in my crontab line and the script delayed for 60 seconds, when it runs, httpd is up and running and has a PID.Here is my Crontab: