tibberous Posted April 19, 2008 Share Posted April 19, 2008 When I type the line, crontab -u nobody /home/express/public_html/control/crontabs/process.cron, into putty, it works. Same line, shell_exec("crontab -u nobody /home/express/public_html/control/crontabs/process.cron"); Doesn't work. /etc/crontab and /usr/bin/crontab are both set to 777. I tried changing crontab to /usr/bin/crontab I just don't know what else to do, shell_exec doesn't seem to work anything like real shell commands. I get NO output, it just doesn't work. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/ Share on other sites More sharing options...
Northern Flame Posted April 19, 2008 Share Posted April 19, 2008 do you get any errors? Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521491 Share on other sites More sharing options...
tibberous Posted April 19, 2008 Author Share Posted April 19, 2008 No. I think my problem might because PHP is running it as nobody, and I'm running it as root, but there is no reason why it should matter because I changed the permissions on everything. ... If I set UID, it doesn't let me run the script at all. Is there a way to set PHP to run everything as root? Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521504 Share on other sites More sharing options...
tibberous Posted April 19, 2008 Author Share Posted April 19, 2008 I created a new user, and ran the line: su shell -c "/usr/bin/crontab -e" And I get: cron/shell: Permission denied Even though the file is set to 777. If I wanted an unusable level of security, I would have used Vista. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521580 Share on other sites More sharing options...
jonsjava Posted April 19, 2008 Share Posted April 19, 2008 does your apache user have access to crontab? each user (including apache2 or www-root) gets their own user rights. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521581 Share on other sites More sharing options...
discomatt Posted April 19, 2008 Share Posted April 19, 2008 If the file is set to 777, every user should get permission. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521585 Share on other sites More sharing options...
jonsjava Posted April 19, 2008 Share Posted April 19, 2008 not the file. Does your apache user have access to use crontab? Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521586 Share on other sites More sharing options...
tibberous Posted April 19, 2008 Author Share Posted April 19, 2008 How can I tell? I don't think anyone except root can use the -u, and -e opens it up in vim. I can change the file, but the changes don't update unless I use crontab -u. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521604 Share on other sites More sharing options...
jonsjava Posted April 19, 2008 Share Posted April 19, 2008 do this: figure out which username your web service runs under: cat /etc/passwd Next, as root: su <username> then attempt to run the code as them If it fails, then the apache user can't run it. Link to comment https://forums.phpfreaks.com/topic/101899-shell_exec-wont-work-with-crontab/#findComment-521608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.