Go to Cpanel > Cron Jobs, create new cron job.
Select / modify the scheduling, then add the command:
php /home/xx/public_html/job.php
or
/usr/local/cpanel/3rdparty/bin/php /home/xx/public_html/job.php
As a lazy user, I want to get alerted when website goes down.
Solution:
$homepage = file_get_contents('http://,monitoring--domain.com/'); if(strlen($homepage) > 0) { echo "Got response, no action"; }else { echo "No response from server, send out email..."; $to = '[email protected]'; $subject = 'Weak up, you website is down!'; $message = 'Weak up, you website is down!'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); }
PHP has a shell_exec command: “Execute command via shell and return the complete output as a string ” http://php.net/manual/en/function.shell-exec.php
And here is a project: http://phpshell.sourceforge.net/
PHP Shell is a shell wrapped in a PHP script. It’s a tool you can use to execute arbitrary shell-commands or browse the filesystem on your remote webserver. This replaces, to a degree, a normal telnet connection, and to a lesser degree a SSH connection.
You use it for administration and maintenance of your website, which is often much easier to do if you can work directly on the server. For example, you could use PHP Shell to unpack and move big files around. All the normal command line programs like ps, free, du, df, etc… can be used.
Download and config phpShell,, and then upload to your server, then you can run shell!
http://phpshell.sourceforge.net/
/** * 将指定Array内的元素复制到目标Array中, 如果具有相同key, 则会被覆盖. **/ public static function copyArrayItems($source, $target) { foreach($source as $sourceItemKey=>$sourceItemValue) { $target[$sourceItemKey] = $sourceItemValue; } return $target; } /** * 移除$target数组中中带有 $source中元素相同key的元素. * @param $source * @param $target * @return unknown_type */ public static function removeArrayItems($source, $target) { foreach($source as $sourceKey => $sourseValue) { unset($target[$sourseValue]); } return $target; }
有关数组的操作: http://liguoliang.com/2010/php-array-简单操作小结/
实例:
$value= 5.1; echo ceil($value); // 6 echo floor($value); // 5 echo round($value); // 5 echo intval($value); // 5
// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.