Hi,
I have a script for reload services, in this case Tomcat .
I want that only root can run the batch
Can you suggest an efficient way ?
my script
#!/bin/bash
if [ $(date "+%k") -lt 8 -o $(date +"%k") -gt 17 -o $(date +"%a") == "Sat" -o $(date +"%a") == "Sun" ]
then
echo "Cannot run between 09:00 and 18:00"
echo "Non e' possibile eseguire il Reload di Tomcat prima delle ore 09:00 e dopo le ore 18:00"
else
echo "Run Program Tomcat"
echo "Reload di Tomcat"
case $1 in
stop)
echo "/command/sv down /service/tomcat_a"
;;
start)
echo "/command/sv up /service/tomcat_a"
;;
restart)
echo "/command/sv down /service/tomcat_a"
#sleep 20
#rm -rf /opt/tomcat/work/Catalina/*
#sleep 20
echo "/command/sv up /service/tomcat_a"
;;
kill)
echo "/command/sv down /service/tomcat_a"
echo "/command/sv kill /service/tomcat_a"
;;
*)
echo "Usage: $0{stop|start|restart|kill}"
;;
esac
fi
Thanks
I have a script for reload services, in this case Tomcat .
I want that only root can run the batch
Can you suggest an efficient way ?
my script
#!/bin/bash
if [ $(date "+%k") -lt 8 -o $(date +"%k") -gt 17 -o $(date +"%a") == "Sat" -o $(date +"%a") == "Sun" ]
then
echo "Cannot run between 09:00 and 18:00"
echo "Non e' possibile eseguire il Reload di Tomcat prima delle ore 09:00 e dopo le ore 18:00"
else
echo "Run Program Tomcat"
echo "Reload di Tomcat"
case $1 in
stop)
echo "/command/sv down /service/tomcat_a"
;;
start)
echo "/command/sv up /service/tomcat_a"
;;
restart)
echo "/command/sv down /service/tomcat_a"
#sleep 20
#rm -rf /opt/tomcat/work/Catalina/*
#sleep 20
echo "/command/sv up /service/tomcat_a"
;;
kill)
echo "/command/sv down /service/tomcat_a"
echo "/command/sv kill /service/tomcat_a"
;;
*)
echo "Usage: $0{stop|start|restart|kill}"
;;
esac
fi
Thanks