daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Apr 20th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. use for cpanel
  4. - create a table: “tasklog” table.
  5. create table tasklog (
  6.   id int not null auto_increment,
  7.   created datetime,
  8.   primary key (id)
  9. )
  10. */
  11. /**
  12.  * simple code to add job: public_html/taskrun.php
  13.  */
  14. try {
  15.   $host = "localhost";
  16.   $dbname = "your_database";
  17.   $user = "your_db_user";
  18.   $pass = "your_password";
  19.  
  20.   # MySQL with PDO_MYSQL
  21.   $db = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
  22.   $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  23.  
  24.   $stmt = $db->prepare("INSERT INTO tasklog(`created`) VALUES(NOW())");
  25.   $stmt->execute();
  26.  
  27.   $db = null;
  28. }
  29. catch(PDOException $e) {
  30.     echo $e->getMessage();
  31. }
  32.  
  33. /**
  34.  * Register cron job
  35. */
  36. // in cpanel create new job with a one minute frequency.
  37. /usr/local/bin/php "$HOME/jobs/taskrun.php" > /dev/null 2>&1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top