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

How to delete videos from your Youtube Watch History list?

How to Delete Individual or all videos from your Youtube Watch History list? Youtube keeps a fine record of the videos that you had watched earlier. You can view this by visiting the History section. If you want to remove the video's from the list do the following: Logon to Youtube and click on the "History" tab on the left menu to view Watch History ( Read more ) There will be check boxes corresponding to each video in the list Tick the check boxes of the videos which you want to remove Click on " Remove " button to delete the videos.

ICICI prudential Customer portal updated - Option to change password is missing - Know how to change your ICICI prudential password

Recently I received an SMS from ICICI prudential asking for login to their website's customer portal using the phone number as user Id and an autogenerated one time password given in the message as password. The SMS messsage was like this. Dear ***Cust Name*** login to your policy(ies) on www.iciciprulife.com with your user id as **mobile number*** and One time use password as ***password***

What are the Income Tax Rates for Indian citizens for Financial Year 2017-2018?

Income Tax Slab and Rates given below are for Indian citizens of age less than 60. This rates are applicable for the Financial Year 2017-2018 Income Tax Slab Rates Financial Year 2017-2018 Assessment Year 2018-19 Income Tax Slab Rates SLAB 1 Individuals whose total income not exceeding Rs. 2,50,000 ( 2.5 lakhs ) They are exempted from paying income tax.


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