Setting Up Non Stop Cron Job With PHP Script

Create a php File

https://example.com/cron/cron_nonstop.php



$url='https://example.com/cron_script.php';
if(strlen($url)>1)
{ echo "url :".$url; if(isset($_REQUEST['debug']) and (@$_REQUEST['debug']==1) ) { exit; } header("Location: $url"); die;
}
else
{ echo "
No Url";
}



mkdir bashcron
cd bashcron
nano bash_nonstop.sh
chmod 0755 bash_nonstop.sh
nohup ./bash_nonstop.sh &
#!/bin/bash
webserv="https://example.com/cron/cron_nonstop.php"
keyword="SCRIPT COMPLETED" # enter the keyword for test content
flag="1"
i="0"
#while [[ $flag -gt 0 ]] && [[ $i -lt 5 ]]
while [ $flag -gt 0 ]
do
if curl -m 5 -s -L "$webserv" | grep "$keyword"
then
# if the keyword is in the conent
echo " the website is working fine"
else
#echo "Error"
#flag=0
sleep 10
fi
i=$[$i+1]
sleep 1
done
cd /root/bashcron
nohup ./bash_nonstop.sh &
ps aux | grep -i 'bash_nonstop'
echo "" > nohup.out


Dated : 2020-10-13 18:46:25

Tags : Php Programming

Leave Your Comment