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.

How to add "Link to this page" option under blogger posts?

Steps in adding Link to this page to your blogger posts Links to your page can improve your page rank. So it is a good option to add HTML code for linking to your web page. So that reader can copy and paste it on their web page. if another website links to your web page, this is considered an external link to your website. External links to your website are the most important source of ranking power and in SEO terminology it is considered as third party ranking vote for your page.

Intex Aqua 5.5 VR Plus genuine Review - Dont Buy Intex Aqua 5.5 VR Plus - Board complaint and low battery backup issues

Intex Aqua 5.5 VR Plus  Review - Dont Buy Intex Aqua 5.5 VR + - Board complaint and low battery backup issues I bought an Intex Aqua 5.5 VR Plus on April 23, 2018, With in a week it started to show Battery backup issues. Even if it is charged full, it will completely drain out with in 12 or 13 hours. During this time No internet was used, only 2 or 3 calls were done. Some times there was issues with net connection also.


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