Issue
So I have an issue where my cron job isn't running. I've never used cron before so it might just be me not knowing how to set this up properly, but I don't think it is. I set up the cron job in cpanel, and it runs to my main website directory where "test.php" is located.
It works absolutely fine if I manually go to the page(By entering the domain/test. But doesn't work at all with cron, so I know this issue isn't with the function but with the cron. I currently have it set to run every minute, just for testing purposes. Any help would be greatly appreciated, thanks :)
Cron:
* * * * * /usr/local/bin/php -q /home1/website/public_html/test.php
PHP
<?php
require("../backend/backend.php");
$id = "4127684511423";
sendChannelMessage($channelid);
?>
Solution
The __DIR__
would give the script working directory so when using require
it would always translate the path correctly
example:
<?php
define('DIR', __DIR__);
require_once(DIR.'../backend/backend.php');
?>
Answered By - Noam Yizraeli