我正在使用 CentOS 7,我的目标是每五秒创建一个 cron,但正如我研究的那样,我们只能使用 cron 一分钟,所以我现在正在做的是我创建了一个 shell 文件。
命中.sh
while sleep 5; do curl http://localhost/test.php; done
Run Code Online (Sandbox Code Playgroud)
但我通过右键单击它手动点击了它。
我想要的是为该文件创建一个服务,以便我可以自动启动和停止它。
#!/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 …Run Code Online (Sandbox Code Playgroud)