neugi Posted July 11, 2006 Share Posted July 11, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/ Share on other sites More sharing options...
hvle Posted July 11, 2006 Share Posted July 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56130 Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56180 Share on other sites More sharing options...
hvle Posted July 11, 2006 Share Posted July 11, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56186 Share on other sites More sharing options...
neugi Posted July 11, 2006 Author Share Posted July 11, 2006 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 createdbest Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56197 Share on other sites More sharing options...
ShogunWarrior Posted July 12, 2006 Share Posted July 12, 2006 Maybe the cron job should be run as [b]www-data[/b] so it has server write access? Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56548 Share on other sites More sharing options...
neugi Posted July 12, 2006 Author Share Posted July 12, 2006 with user www-data there is also no wirting of the file :(best Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56746 Share on other sites More sharing options...
ShogunWarrior Posted July 12, 2006 Share Posted July 12, 2006 Is there a way to specifiy the working directory for the cron job? Quote Link to comment https://forums.phpfreaks.com/topic/14265-cronjob-php/#findComment-56810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.