Manage cookies that are used for advertising, such as ad personalization, remarketing, and ad effectiveness analysis.
2.12.8. Change cron working directory
The default working directory for running cron tasks is home.
PHP script
Add the following lines to the beginning of the script being launched (use your own site name and path):
$_SERVER['HTTP_HOST'] = 'example.com';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';
chdir('/home/example/example.com/www/path/to/dir');
Linux commands
Use this method if you get an error like "cd: No such file or directory" when you start the task.
- Create a file with any name (for example,
cron.sh) on the hosting server with the following content:#!/bin/bash here, specify the commands to be run - Add a cron task and specify the path to the created file as the task itself.