matfish Posted March 27, 2009 Share Posted March 27, 2009 Hi there, I have a .php script which outputs some stats and emails them to me. I then have a .sh script that then curl's the php script on the webspace. And then a cron which invokes the .sh script. If I log in via ssh as root and run the script or run the php script manually - all works fine. But if I let the cron invoke the script then I get the email but there are no stats attached? If this an issue with cron or php? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/ Share on other sites More sharing options...
corbin Posted March 27, 2009 Share Posted March 27, 2009 Perhaps it has something to do with running it as root and cron probably does not run it as root. By the way, why are you cURLing it? Why not put it out side of the web space and use the PHP CLI? Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-795211 Share on other sites More sharing options...
matfish Posted April 1, 2009 Author Share Posted April 1, 2009 Hi there, forget about the above issue - It seems to be an issue on PHP script. I do have another issue through and you kind of answered it above but still need a bit of guidence. I use Plesk/RedHat5 and set up a crontab to run a .sh script on the server. I can see that ls -lut * in the shell's directory that the crontab is hitting the script at the correct time, but the .sh script is not doing anything. If I run the script as root in ssh it works fine. You mentioned that cron is probably not running cron as root. Do I have to "chown user:user *" the files to something else as I'm not sure who it would be running as? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-798496 Share on other sites More sharing options...
trq Posted April 1, 2009 Share Posted April 1, 2009 Do I have to "chown user:user *" the files to something else as I'm not sure who it would be running as? The script will be executing as the user whom setup the crontab. eg; If you log in as Jo and setup a crontab, the scripts within that crontab will be executed as though Jo was executing them. if you setup the scripts within roots crontab root will execute the scripts. Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-798533 Share on other sites More sharing options...
matfish Posted April 2, 2009 Author Share Posted April 2, 2009 Hi there, I thought I understood the above but when I tried it still did not work. I logged in via Plesk as "admin" chose the domain "123.com" hit "Crontab" and set up the crontab under the system user "123_user". However the .sh script was created as "root" directly via SSH. Any ideas from the above the chown permissions should be? I can still see that the script is being hit by cron, but nothing's happening. Many thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-799276 Share on other sites More sharing options...
trq Posted April 2, 2009 Share Posted April 2, 2009 Ive never used plesk (much rather using the shell itslef) but it would seem to me if your logging in as admin then your script will execute as the admin user. Does the script actually need to be run as root? And if so, why? Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-799529 Share on other sites More sharing options...
matfish Posted April 2, 2009 Author Share Posted April 2, 2009 I've tried chown admin:admin / admin:root / root:root / and still its hitting the .sh script but not actually running it. As a test the .sh script just "mkdir testdirectry" and... nothing! It doesnt have to run as root or admin as long as it runs! When I logged into ssh using root it was fine. When I logged into ssh as admin there was a permissions error - but I fixed it and it runs from ssh as admin now - but nothing when using cron? How do I find out what cron is running as? Any other ideas? It's doing my head in! Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-799589 Share on other sites More sharing options...
matfish Posted April 3, 2009 Author Share Posted April 3, 2009 Ok, so I kind of figured it out. I had to use the Plesk user psacin user instead of admin or root to run the system users of the domains set up in Plesk. Thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-800157 Share on other sites More sharing options...
steviewdr Posted April 3, 2009 Share Posted April 3, 2009 Glad you got it. Thanks for letting us know how you sorted it. *steviewdr marks this topic as solved -steve Quote Link to comment https://forums.phpfreaks.com/topic/151358-solved-phpcronroot-issue/#findComment-800498 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.