Bash script that executes php file every 5 seconds

后端 未结 6 1938
孤街浪徒
孤街浪徒 2020-12-22 06:09

Bash script:

$ cat test.sh
#!/bin/bash
while true
do
 /home/user/public_html/website.com/test.php
 sleep 5
done

Im trying to call it with c

6条回答
  •  天命终不由人
    2020-12-22 06:36

    You missed the & character to put the process in the background :

    #!/bin/bash
    while true
    do
     /home/user/public_html/website.com/test.php &
     sleep 5
    done
    

    Ensure your script is eXecutable :

    chmod +x /home/user/public_html/website.com/test.php
    

    but to combine cron and this script, there's one way :

    @reboot /path/to/script.sh
    

    because you need only one instance of your script.

    If you cron doesn't support @reboot, another possibility is to add a line in /etc/rc.local

提交回复
热议问题