我使用CentOS 7的目的是每五秒钟创建一个cron,但正如我研究的那样,我们只能使用一分钟的cron,所以我现在要做的是创建一个shell文件。
hit.sh
while sleep 5; do curl http://localhost/test.php; done但是我已经通过右键单击来手动点击它。
我想要的是为该文件创建服务,以便我可以自动启动和停止它。
#!/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 但是我不知道在start或stop方法中该写些什么,我试图将hit.sh的相同内容放入其中,start(){}但是}in stop方法却给出了错误。
/usr/bin/myscript.sh可以通过终端执行正常,并echo$?给了我1
                
/usr/bin/myscript运行它是否可以正常工作?echo $?脚本完成运行后的输出是什么?是203吗?