Home   Best Sellers   Blogging   Coding & Design   Technology   SEO   Travel & living   Career   Videos   Tips   Calculators     
Home  »     »     »     »  Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts via Cron Task Scheduler

Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts via Cron Task Scheduler

Friday, July 25, 2014

Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts through Cron Task Scheduler

I have a php script. https://www.myserver.com/crontasks/checktask.php

I tried to run the tasks from the command line as the user that owns them. The tasks executed normally

ssh /usr/bin/php /var/www/vhosts/myserver.com/httpsdocs/crontasks/checktask.php

But it fails when set as a scheduled task from plesk panel using command path


/usr/bin/php /var/www/vhosts/myserver.com/httpsdocs/crontasks/checktask.php

I had directed the cron output to my email address (which i set to notify when the cron task is initiated) , and soon I started receiving this error in my email :

-: /usr/bin/php: No such file or directory

==========

Reason:

Plesk 10 inserts the following line into the crontab file for each users :

SHELL=/usr/local/psa/bin/chrootsh

This breaks the cron jobs, because it forces users to try to run cron tasks in a chroot wrapper or Jail. This error happens when the user is restricted to a chroot jail and the php binary doesn’t exist within that jail. You can manually remove the lines but Plesk will restore them when the job is edited. An option, is to run this command on the server:

/usr/local/psa/bin/server_pref -u -crontab-secure-shell /bin/sh

This changes the SHELL setting to a normal default value

============

From the Plesk 10.3.1 Administrator’s Guide I got this information

Given under topic  "Configuring the Server Execution of Scripts via Cron Task Scheduler (Linux Hosting)" on page 166
In previous versions of Plesk, the users who were granted the permission to schedule tasks with cron but were not allowed access to server shell, could still run scripts in the shell under which the cron was running. This allowed them to gain access to the data that could be potentially used to compromise the server. Starting from Parallels Plesk Panel 10.1, execution of cron tasks is automatically restricted to the chrooted shell environment. This is the default setting applied on clean installations of Panel 10.1 and in cases when data were migrated from other platforms or earlier Plesk versions. If you upgraded to Parallels Plesk Panel 10.1 from previous versions (including 10.0), then the chrooted shell is not automatically selected so as not to break execution of any scheduled tasks that your customers could have running.

If you trust your customers enough to allow execution of scripts in a non-chrooted environment, then you can select the required shell by issuing the following command in the console:

# /usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"

If you want to revert this setting and set again the default shell used by the system, issue the following command in the console:

# /usr/local/psa/bin/server_pref -u -crontab-secure-shell ""


=============

If your user has the chrooted shell:

then it will be

SHELL=/usr/local/psa/bin/chrootsh

so it wont allow to run the cron from /usr/bin/php

You can change the shell so that they are not chrooted. but as per above documentation this will give the user access to data outside of their directory .

============

So to fix the cron issue all you have to do is run the following command

/usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"

Now probably your cron tasks would start working.


Download and Read Plesk 10.3.1 Administrator’s Guide   ( Check content under topic  "Configuring the Server Execution of Scripts via Cron Task Scheduler (Linux Hosting)" on page 166 )



How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts via Cron Task Scheduler.




Share this!




comments powered by Disqus

This Weeks 7 Popular Posts


Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   



Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »