While setting up a cron job from cPanel or Simple Control Panel you will encounter Warning messages like failed to open stream. But the file may works perfectly from the browser.
Error like this,
Warning: main(home/default/cron.php): failed to open stream: No
such file or directory in
/home/abc/xyz.com/includes/sampple.inc
on line 1
This is because, the script not running from the current directory. For solving the issue you need to initialize the current directory.
Add the below code to the start of your cron script file. This will change to current directory and hence all the issues will be solved.
chdir( dirname ( __FILE__ ) );
?>
No comments:
Post a Comment