I'm using CentOS 7 what my aim is to create a cron for every five seconds but as I researched we can use cron only for a minute so what I am doing now is I have created a shell file.
hit.sh
while sleep 5; do curl http://localhost/test.php; done
but I have hit it manually through right clicking it.
What I want is to create a service for that file so that i can start and stop it automatically.
I found the script to create a service
#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....
# Source function library.
. /etc/init.d/functions
start() {
# code to start app comes here
# example: daemon program_name &
}
stop() {
# code to stop app comes here
# example: killproc program_name
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
# code to check status of app comes here
# example: status program_name
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
But I don't know what to write in start or stop methods I tried placing the same content of hit.sh in start(){}
but it gave error for }
in stop method.