I would like to set a job to run daily in the root crontab. But I would like it to execute it from a particular directory so it can find all the files it needs, since the application has a bunch of relative paths.
Anyway, can I tell crontab to run from a particular directory?
All jobs are executed by a shell, so start that shell snippet by a command to change the directory.
Concerning the use of
&&instead of;: normally it doesn’t make a difference, but if thecdcommand fails (e.g. because the directory doesn’t exist) with&&the application isn’t executed, whereas with;it’s executed (but not in the intended directory).