What are some common methods for setting up a CronJob in PHP?

Setting up a CronJob in PHP allows you to schedule and automate the execution of certain tasks at specific intervals. One common method for setting up a CronJob in PHP is to create a PHP script that contains the task you want to run and then use a CronTab entry to schedule the script to run at the desired frequency.

// PHP script to be executed by the CronJob
<?php
// Your task code here
echo "CronJob executed at " . date('Y-m-d H:i:s') . "\n";
?>

// CronTab entry to schedule the PHP script to run every day at 2 AM
0 2 * * * php /path/to/your/script.php