Jump to content

Data folder of scheduled tasks is different than of manual script run - how to deal with this


Recommended Posts

Posted

I have a website where I need to save and load some local data, which is done by php scripts. I noticed the following:

  • When I manually run my php scripts, e.g. by typing their file name in a web browser, files are read and written to the httpdocs folder
  • When the scripts are called via a scheduled task, files are read and written to the home folder.

 

I both use scheduled tasks and manual script runs. Does anyone know a practical way how to deal with this?

Posted (edited)

Use absolute paths to the files in the scripts instead of relative ones. Your home folder is at /home/weer.helioho.st/ so absolute paths would be in the form: /home/weer.helioho.st/httpdocs/filename.txt

You can also make the path dynamic. This statement means "filename.txt in the same folder as the PHP file":

dirname(__FILE__).'/filename.txt'

 

Edited by wolstech

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...