为cron作业编写php脚本以执行函数的步骤[关闭]

I need to implement a cron job which run everyday at 8:00 AM.I don't have any idea what needs to be done. the cron should run the a function greet() on this file.

<?php
    class Person {
     public $age=0;
     public  $isalive=false;
     public $name;
     public $msg;
     public $isAlive=true;
     public $firstname;
     public $lastname;

     public function __construct($fname,$lname,$age){
        $this->firstname=$fname;
        $this->lastname=$lname;
        $this->age=$age;
        $this->name=$fname." ".$lname;
        //$this->isAlive=$isAlive;
     }

         public function greet(){
             echo "$this->name says $this->msg my age is $this->age <br> am I alive:$this->isAlive";
         }
    }
     $teacher = new Person('boring','12345',12345);
     $student = new Person('Swapnil','Shende',24);
     echo $student->age;

     ?>

Go to the cron tab and open it like this

crontab -e

then add this line

* 8 * * *   filename.php

where filename.php is your file name

Also edit your file.php to call those function like this at the end

 $teacher = new Person('boring','12345',12345);
 $student = new Person('Swapnil','Shende',24);
 $student->greet();
 $teacher->greet();
crontab -e
* 8 * * *  file.php

where file.php contain:

<?php
include ('Person.class.php');
$teacher = new Person('boring','12345',12345);
$student = new Person('Swapnil','Shende',24);
$teacher->greet();
$student->greet();
?>

and delete this part from your class

$teacher = new Person('boring','12345',12345);
$student = new Person('Swapnil','Shende',24);
echo $student->age;