Cron job permission denied

Category: Cpanel

BradCraw
Asked:
2014-03-27 6:32 pm EST

Hits: 1,806
I set up a cron job in Cpanel according to instructions from my CMS software but received this email alert:
/usr/local/cpanel/bin/jailshell: /usr/bin/wget: Permission denied

The cron I tried to run was:
wget --tries=1 --timeout=99999 -0 cron.txt http://www.example.com

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User

1

JacobIMH
Staff
9,968 Points
2014-03-27 6:47 pm EST
Hello BradCraw, and thanks for your question.

If you are trying to run a cron job on shared hosting, it's important to note that wget is disabled for security reasons.

You can instead utilize curl if you need to download a remote file, being sure to also define a user-agent so that it doesn't trip a ModSecurity error:

/usr/bin/curl --user-agent CronJob --retry 1 --max-time 60 -o cron.txt http://example.com



Please let us know if you're still having any issues at all.

- Jacob

You must login before you can post a comment about this answer.

Thanks Jacob. I'll give it a shot. I copied everything you had exactly up to the URL so we'll see what happens. Would be nice if there was a way to run it now instead of having to wait for the scheduled time. Oh well. I'll report back tomorrow around noon. :-)
BradCraw
14 Points
2014-03-27 6:57 pm EST
Hello BradCraw,

No problem at all. If you'd like to test out the script right away instead of waiting for the cron job to run. You could simply place this code in a file called something like crontest.php

<?php

exec ("/usr/bin/curl --user-agent CronJob --retry 1 --max-time 60 -o cron.txt http://example.com");

?>


Then you would just access that PHP script on your site like example.com/crontest.php. If you didn't receive any errors, then you should be able to access the output file at example.com/cron.txt with the results of the remote file grab.

Please let us know if you had any other questions at all.

- Jacob
JacobIMH
9,968 Points
Staff
2014-03-27 7:42 pm EST
Thanks again Jacob. I received this error report this morning when it ran:
curl: Remote file name has no length!
curl: try 'curl --help' for more information

curl: (60) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

Do I need to do something special since my site has SSL? I think I'm just going to upgrade to VPS account for this and other reasons. But thought I would post this for anyone else with problems.
BradCraw
14 Points
2014-03-28 3:34 pm EST
Hello again BradCraw,

It looks like you just left over the syntax for wget using -O cron.txt which isn't a command in curl. You instead want to use a lowercase -o cron.txt.

I've gone ahead and made this adjustment in your cron job for you.

Also it doesn't look like there is anything at the URL you are trying to request from, you'll want to make sure that there is actual content at the URL you're trying to have curl request from, otherwise you won't end up with any output in your cron.txt file.

Connecting to a site with an SSL certificate shouldn't matter, I believe you were just getting the SSL error because it didn't understand the -O flag you were passing to the command.

Please let us know if you're still having any issues at all.

- Jacob
JacobIMH
9,968 Points
Staff
2014-03-28 3:55 pm EST
It worked. I tested it using the PHP exec method you gave me and after you changed the capitol O to lowercase, it ran without error. I logged into my CMS and it does show that it ran with no errors. There must be some sort of redirect because the folder the cron.txt file is supposed to be located in doesn't even exist. But it works so I'll happy. Thanks Jacob. You've been very helpful.
BradCraw
14 Points
2014-03-28 4:14 pm EST
Hello again BradCraw,

Glad to hear that's working now! When you specify the output file as just -o cron.txt in your cron job. This file should be placed in your main home directory at /home/userna5/cron.txt.

You could also enter in a full path if you wanted it to be available from your website like -o /home/userna5/public_html/cron.txt which you could then access from example.com/cron.txt.

Please let us know if you had any other questions at all!

- Jacob
JacobIMH
9,968 Points
Staff
2014-03-28 5:03 pm EST
Like this Question?

Support Center Login


Social Media Login

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!