Page 1 of 2
User write access
Posted: Mon May 14, 2007 7:43 am
by kbrown3074
I am having a problem with pages I am trying to have run thru a cron job. I can run the pages via the webpage itself, but thru a command line on the server it does not work. There is a similiar job running on a different directory and it works fine. The directory access is the same on both directories. Both directories only have root as the user. I know there is something Im missing..just not sure what to check.
Posted: Mon May 14, 2007 8:35 am
by Jenk
cron jobs will run as root, whilst when you view them in your browser, they will run as the webserver's user, not root.
Posted: Mon May 14, 2007 9:01 am
by kbrown3074
My problem is that for some reason I cant get the new shell script to create files in the new directory. The existing script works fine and the directory has the same read/write attributes. I am getting the below error while trying to write to the directory thru the command line
Code: Select all
Can't create/write to file '/var/www/htdocs/daily_edts/sheets/2007_05_14_treeleads.txt' (Errcode: 2)
Posted: Mon May 14, 2007 9:06 am
by Jenk
what's the output of:
Code: Select all
ls -l /var/www/htdocs/daily_edts/sheets/2007_05_14_treeleads.txt
Posted: Mon May 14, 2007 9:38 am
by kbrown3074
nothing..file doesnt exist
Posted: Mon May 14, 2007 9:56 am
by Jenk
output of:
Code: Select all
ls -l /var/www/htdocs/daily_edts/sheets/
?
Posted: Mon May 14, 2007 12:59 pm
by kbrown3074
Code: Select all
root@seq2:~# ls -l /var/www/htdocs/daily_reports/sheets
total 404
-rw-r--r-- 1 root root 9728 2007-05-13 06:55 aaasj2007-05-13.xls
-rw-r--r-- 1 root root 14848 2007-05-13 06:55 Cobra2007-05-13.xls
-rw-r--r-- 1 root root 5632 2007-05-13 06:55 confirmobleads2007-05-13.xls
-rw-r--r-- 1 root root 6144 2007-05-14 06:55 confirmobleads2007-05-14.xls
-rw-r--r-- 1 root root 11264 2007-05-10 09:15 cont66ib2007-05-10.xls
-rw-r--r-- 1 root root 12800 2007-05-13 06:55 cont66ib2007-05-13.xls
-rw-r--r-- 1 root root 21504 2007-05-13 06:55 cont66ob2007-05-13.xls
-rw-r--r-- 1 root root 4096 2007-05-13 06:55 cont66obleads2007-05-13.xls
-rw-r--r-- 1 root root 8704 2007-05-14 06:55 cont66obleads2007-05-14.xls
-rw-r--r-- 1 root root 4096 2007-05-13 06:55 cont66pt2007-05-13.xls
-rw-r--r-- 1 root root 5120 2007-05-14 08:14 cont66pt2007-05-14.xls
-rw-r--r-- 1 root root 39936 2007-05-13 06:55 dtree2007-05-13.xls
-rw-r--r-- 1 root root 12800 2007-05-13 06:55 gwoeib2007-05-13.xls
-rw-r--r-- 1 root root 20480 2007-05-13 06:55 gwoeob2007-05-13.xls
-rw-r--r-- 1 root root 4096 2007-05-13 06:55 gwoeobleads2007-05-13.xls
-rw-r--r-- 1 root root 4096 2007-05-14 06:55 gwoeobleads2007-05-14.xls
-rw-r--r-- 1 root root 4096 2007-05-13 06:55 gwoept2007-05-13.xls
-rw-r--r-- 1 root root 5120 2007-05-14 08:14 gwoept2007-05-14.xls
-rw-r--r-- 1 root root 13312 2007-05-13 06:55 ibcib2007-05-13.xls
-rw-r--r-- 1 root root 20480 2007-05-13 06:55 lifesec2007-05-13.xls
-rw-r--r-- 1 root root 12288 2007-05-13 06:55 ltcib2007-05-13.xls
-rw-r--r-- 1 root root 9216 2007-05-13 06:55 ltcny2007-05-13.xls
-rw-r--r-- 1 root root 21504 2007-05-13 06:55 ltcob2007-05-13.xls
-rw-r--r-- 1 root root 12288 2007-05-14 07:51 medsupib2007-05-14.xls
-rw-r--r-- 1 root root 21504 2007-05-14 07:51 medsupob2007-05-14.xls
-rw-r--r-- 1 root root 22528 2007-05-13 06:55 mhip2007-05-13.xls
-rw-r--r-- 1 root root 12800 2007-05-13 06:55 partdib2007-05-13.xls
-rw-r--r-- 1 root root 21504 2007-05-13 06:55 partdob2007-05-13.xls
root@seq2:~#
Posted: Tue May 15, 2007 3:46 am
by Jenk
ok, I'm going to assume that the directory itself is set for root:root 0644; which would prohibit any user but root from writing to that directory.
You can either change the group ownership to that of the same group as your webservers user and chmod to 0664, or chmod the directory to 0666 which will allow anyone to write (but not execute) the files - I recommend the former.
Posted: Wed May 16, 2007 9:53 am
by kbrown3074
not exactly sure how I would modify the user group. How would I go about doing that?
Posted: Wed May 16, 2007 10:21 am
by Jenk
Posted: Thu May 17, 2007 7:52 am
by kbrown3074
I guess I am completely missing the boat on this one. I thought there would be more than 1 group when I do a groups command..not the case. Seems like something simple to allow the root user to write files to this dir..but it still isnt working...ugh!
Code: Select all
root@seq2:/var/www/htdocs/daily_edts/sheets# groups
root
root@seq2:/var/www/htdocs/daily_edts/sheets#
root@seq2:/var/www/htdocs/daily_edts/sheets# users
root root
root@seq2:/var/www/htdocs/daily_edts/sheets#
Posted: Thu May 17, 2007 8:22 am
by Jenk
have you confirmed your webserver is running as root? It is a) unlikely and b) a bad idea
Posted: Thu May 17, 2007 8:48 am
by kbrown3074
I am not sure..I didnt set it up. I just ssh into it as root. How would I check to see if it is actually running as root?
BTW...if I run the pages that create an xls by itself from the browser, it creates the file. If I run the edts.php that calls all the other pages, nothing gets created.
Posted: Thu May 17, 2007 9:37 am
by Jenk
Ok, before I get anymore muddled.. are you trying to write to the file(s) with your cron job, or from the webserver (prompted by browsing to page in your browser?)
Posted: Thu May 17, 2007 10:33 am
by kbrown3074
I want to be able to do it through the cron job.