Jump to content

Archived

This topic is now archived and is closed to further replies.

neugi

CronJob & PHP

Recommended Posts

Hi,

i've got a script that writes a file to the server. if i run it from the webserver it works okay and writes the file to the server.

but if i run it as an cronjob with this command "php -f /var/www/tmi/output.php" it won't create a file on the server.

do i have to use a other command that the php script writes the file to the server?

best

Share this post


Link to post
Share on other sites
yes, you can use a perl script instead.
PHP run with world permission (module). So unless you set the folder to world writable, It will not create any files.  Perl instead, running with server core, (i don't know whatever you called it), but it can write file anywhere. 
So yeah, if you're unconfortable to chmod your folder to 0777 (which is not recommended), you can use a perl script instead.

Share this post


Link to post
Share on other sites
When you run PHP from a cron job, you can specify the user that the script runs under. Do that and your script will be able to write files with compromising the security of your system.

Ken

Share this post


Link to post
Share on other sites
My host use vdeck 2.0 and it did not have option to specify which user permission for php to run under.  Is there anyway of doing that within the script?

Share this post


Link to post
Share on other sites
Hi,

i run the cronjob as user root so this user should have rights to write data to the server.

all the other stuff is done (read from database) but no file is created

best

Share this post


Link to post
Share on other sites
with user www-data there is also no wirting of the file :(

best

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.