Reputation: 749
folks, i am very new to PHP, on project that i do now(PHP + Linux), i need to schedule tasks. I know that i can do it using cron. How can i check crontab file from PHP(i have only ftp access to server)? I mean i can run 'crontab -l' from terminal(on my local PC). But when i try to do : echo exec('crontab -l'); - on local PC, it retrn nothing, why it happend ? How can i run command 'crontab -l' from PHP and get output ? I've tried to use example http://ryanfaerman.com/read/php-crontab-manager, but get compile error.
Upvotes: 0
Views: 387
Reputation: 749
I got nothing from exec('crontab -l'), because i haven't permissions to run crontab and error message is in error stream, so all i need redirect error stream to out stream. exec('crontab -l 2>&1') - that is exactly i wanted.
Upvotes: 0
Reputation: 23055
I think crontab will open the user's crontab. Your webserver might be running as root or a different user than you would be.
Try this, but I doubt it will work for security reasons:
crontab -u root -l
Upvotes: 2