2.11.8. Changing cron's working directory

The default working directory for running cron jobs is home.

Add to the beginning of the running script:

$_SERVER['HTTP_HOST'] = 'name_site  ';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'GET';
chdir('/home/name_hosting_account/name_site/subdomain/path/to/directory');
Use this method if you get an error like "cd: No such file or directory".
  1. Create a hosting file with any name (for example, cron.sh) and the following content:
    #!/bin/bash
    specify the commands to be run
  2. Add cron task and specify the path to the created file as the task itself.
Content