Cron for website

Community support for Plesk, CPanel, WebMin and others with insight from two of the founders of Plesk. Ask for help here! No question is too simple or complicated. :-)
Troy McClure
Forum Regular
Forum Regular
Posts: 196
Joined: Tue May 10, 2005 1:24 pm

Cron for website

Unread post by Troy McClure »

I have a Plesk 10 server and I have a user that needs to run some php cron scripts that login to their mysql db and make some changes each night. I tried to allow them a chrooted environment, but php and mysql are not available in that environment. I was able to get php running and all the libraries loaded, by copying what was need for them, but I can't get php to load the mysql library. Does anyone know if this is the best way to do this? Is there a better, safer way to allow this? If this is the best way, how do I load mysql with php in this chrooted environment?
Highland
Forum Regular
Forum Regular
Posts: 674
Joined: Mon Apr 10, 2006 12:55 pm

Re: Cron for website

Unread post by Highland »

I thought Plesk did cron jobs for them under their FTP user
"Its not a mac. I run linux... I'm actually cool." - scott
Troy McClure
Forum Regular
Forum Regular
Posts: 196
Joined: Tue May 10, 2005 1:24 pm

Re: Cron for website

Unread post by Troy McClure »

It is run under their ftp user. But that has no access to php. It seems like the cron jobs run chrooted. Is that not right? I enter a job with the command "php -q /path/to/file" and I get "php: command not found" or "/usr/bin/php -q /path/to/file" and I get "/usr/bin/php: No such file or directory".
Troy McClure
Forum Regular
Forum Regular
Posts: 196
Joined: Tue May 10, 2005 1:24 pm

Re: Cron for website

Unread post by Troy McClure »

I do know that I can set the ssh setting under Web Hosting Settings to /bin/bash and it will work, but is that a good idea? If I set that to forbidden (which I normally do), it seems to be chrooted when it runs.
Highland
Forum Regular
Forum Regular
Posts: 674
Joined: Mon Apr 10, 2006 12:55 pm

Re: Cron for website

Unread post by Highland »

So you're testing this with the CLI? And there's two /bin/bash, one is chrooted (at least in mine there is)
"Its not a mac. I run linux... I'm actually cool." - scott
faris
Long Time Forum Regular
Long Time Forum Regular
Posts: 2321
Joined: Thu Dec 09, 2004 11:19 am

Re: Cron for website

Unread post by faris »

Personally I simply do a wget via http.

e.g.:

Code: Select all

wget -q -O /dev/null http://www.whatever.tld/directory/file.php
And I seem to recall that wget has options that allow you to specify username/password credentials, so you can place the file you want to run in a proteted directory so that it doesn't get accidentally run or accessed by anyone.
--------------------------------
<advert>
If you want to rent a UK-based VPS that comes with friendly advice and support from a fellow ART fan, please get in touch.
</advert>
Troy McClure
Forum Regular
Forum Regular
Posts: 196
Joined: Tue May 10, 2005 1:24 pm

Re: Cron for website

Unread post by Troy McClure »

highland - Yes, there are two. If I set it to /bin/bash, the cron job runs fine, but I really don't want to give this user that access to the system. If I set it to /bin/bash (chrooted), I run into the original problem that php is unknown. So that is when I started copying files to to that web users directory so they would have access to php in their chrooted environment. I got all the libraries needed to run php, I just can't get php to use the mysql library. If I could get that part working, I would be set.

faris - Great idea. I might just settle on this idea as it will cause the least amount of configuration changes to get the same result.
Post Reply