Skip to main content

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 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 )

Popular posts from this blog

Sachin Tendulkar's emotional farewell Speech at Wankhede Stadium, Mumbai - Full Text and Video

Full Text and Video of Sachin Tendulkar's emotional farewell Speech on Nov 16, 2014 On November 16, 2013 - Sachin Ramesh Tendulkar played his last international cricket match against West-Indies at the at Wankhede Stadium, Mumbai. After the match he gave an emotional farewell speech. No one would be able forget the speech. The eyes of the gathered people were tearfull. Through out the speech Sachin thanked each and everyone who supported and encouraged him to build up his glorius career which spanned 24 years.

How to loop through the items in a select box using Javascript?

Looping through the items in a select box using JS Use the code given below to parse through the options in a select box and alert the Text and Value of each options. you can alter the function as per your need. sample code is given below: <form> <select id="test" name="test"> <option value="First Value" >First Text</option> <option value="Second Value" >Second Text</option> <option value="Third Value" >Third Text</option> <option value="Fourth Value" >Fourth Text</option> <option value="Fifth Value" >Fifth Text</option> </select> <input type="button" value="Check" onclick="loopSelectBox('test')" > </form> <script> function loopSelectBox(selectBoxId){ var obj=document.getElementById(selectBoxId); for(i=0; i < obj.options.length ;i++){ alert("Value :...

Autobiography by Cricket legend Sachin Tendulkar "Sachin Tendulkar - Playing it My Way : My Autobiography"

Autobiography by Cricket legend Sachin Tendulkar Cricket batting legend Sachin Ramesh Tendulkar's  autobiography was released on November 5, 2014 in a high profile launch function in Mumbai. . Earlier  on his Twitter page Sachin has announced the release date of his Autobiography " Sachin Tendulkar - Playing it My Way : My Autobiography "   as November 6th 2014 , but the book was released a day earlier. It took three years to write this book which he says as the Second innings of his life. Sachin Ramesh Tendulkar, the all time Genius of World Cricket was born on April 24, 1973 at Bombay (now Mumbai) in Maharashtra. He hold the record for scoring most runs and hundreds in Tests and ODIs. He scored a total of more than 34000 runs from One day Internationals (ODI's) and tests. He was part of the World cup winning team of 2011. He was a great all rounder. His  debut match was against    Pakistan  at Karachi during Nov 15-20, 1989. He played h...


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 »
Member
Search This Blog