File path for a Cron Job - cron

Hi I want to run a cron job to call a PHP script on my server. I am using Cpanel from my web host and these are the options:
Minute:
Hour:
Day:
Month:
Weekday:
Command:
I am really struggling to point the command to my file I am using this line /home/abbeysof/public_html/adi/cron/daily.php but I am getting this error:
/bin/sh: /home/abbeysof/public_html/adi/cron/daily.php: Permission denied
I asked my web host for help and this is the response:
If you use cpanel to create it, it will fill in the path for you. Typically /home/username/public_html/etc
Can anyone please offer some advice?

Advise 1: use wget command, wget runs the PHP script exactly as if it was called from the web so the PHP environment is exactly the same of when calling the file from the web, it's easier to debug your script then.
wget -O - http://yourdomain.com/adi/cron/daily.php >/dev/null 2>&1
The cron jobs has to be created going into cPanel cron jobs menu. I don't understand if you have this clear by reading your hoster's answer.
And advise 2: change web hosting, try this one they don't leave you alone.

Sorry, I don't know anything about cpanel, but it sounds like:
if you created the file daily.php, then you need to change the permissions on it
if they created the file, then there's a bug in their creation routine.
Good luck!

try this one
/usr/bin/php -q /home/yourCpanelUsername/public_html/filename.php
for some cpanels it might be like this
/usr/local/bin/php -q /home/yourCpanelUsername/public_html/filename.php

Sounds like you need to make /home/abbeysof/public_html/adi/cron/daily.php executable.

The link might help you.
https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job
There is difference if you are using VPS than sharing hosting for giving the command.
You may need to use user-agent & cPanel-Cron along with your url.
curl --user-agent cPanel-Cron http://example.com/cron.php

Related

How to set cron in cakephp in cpanel on linux server

How do i set the cron command in Cpanel in Linux server i use this it works for me is there any proper way
wget http://www.vloghit.com/crons/send_mail
You should use the full path for wget like /usr/bin/wget instead of just plain wget. Depending on the WHM server configuration the crons might be running as jailed so you might get an error stating that wget command was not found if you do not use the full path to the binary. You are also supposed to receive an email notification from that cron job. Are you geting it? I'm asking because in those email notifications you get also an error message that can help you to understand why the cron was not working.

cPanel cron job, no input file specified?

I've just set up my first cron-jon to run a stock script every night.
Running it manually works fine.
It's stored in /admin/stock_update.php
The command i'm running is /usr/bin/php -q /admin/stock_update.php
But I'm getting emails saying no input file is specified?
Any ideas?
Cheers
Network services almost never expose actual paths on the server's hard disk drive and even if they could it isn't a behaviour you can rely on. So the fact that your file is located at /admin/stock_update.php in the FTP server doesn't say much about actual location on disk, which is what local command-line utilities expect.
In PHP, you can find path on disk of current file with the __FILE__ magic constant. You can create a test script:
<?php
var_dump(__FILE__);
... upload it to the same FTP location and execute through the web server. If that's not an option because files in your FTP account in not visible from the web you can run the file from cron and check the email.
Do you have CloudLinux kernel installed on that server and CageFS filestyem? If yes try running this:
cagefsctl -w cpaneluser; cagefsctl -m cpaneluser
Then try running the cron again

Why is my cron job not running?

I am trying to run a cron job at 5:20pm as below but it's not working.
20 17 * * 1 /usr/bin/php /home/myacc/public_html/job/generate.php
I basically did crontab -e and entered the above line there and saved the file.
If I try running the command directly from the command line as below, it works fine:
php /home/myacc/public_html/job/generate.php
What am I doing wrong?
Also, how do I send a message from the cron to either a log file or email so that I know what's going on?
You can record all the logs of your cronjobs by installing postfix and configuring it as local domain during installation. Such that you can see the logs of your cron jobs by vi /var/mail/<user-name>. Try looking the logs and figure out the problem. If you don't find any solution post the log so that it will help others to diagnose the problem. I'm adding this as an answer instead of comment because i think I'm answering your second query.

Jenkins error on building command?

I am new to Jenkins, starting now.
I see the following errors here.
Building in workspace /var/lib/jenkins/workspace/GIF_DECODER
[GIF_DECODER] $ /bin/bash /tmp/hudson3370393570271110742.sh
/tmp/hudson3370393570271110742.sh: line 2: cd: /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX: Permission denied
/var/lib/jenkins/workspace/GIF_DECODER
I have given the build commands as the following. This is under execute shell.
#!/bin/bash
cd /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX
pwd
make clean
make everything
I am not understanding what is the issue here? Looks to be a permission year. I have jenkins in sudoers list. I don't why it looks for /var/lib/jenkins/workspace/GIF_Decoder.
I see the jenkins page under - http://:8080/job/GIF_DECODER/configure
How can I setup the hostname so that instead of localhost I have some meaningful name? Please help. Also, what is the best document/video to start with Jenkins for linux users? How to debug Jenkins issue seen? How can I instantiate a build by sending an email?
I am not understanding what is the issue here?
It's a permission error. It looks like your jenkins user does not have permissions for /home/joshis1/Data/E-Drive/Blog/Ready_to_post/Ubuntu/GIF_Decoder_LINUX
How can I setup the hostname so that instead of localhost I have some meaningful name?
Try the hostname of your server in the URL. e.g. http://myserver:8080/job/GIF_DECODER/configure
Also, what is the best document/video to start with Jenkins for linux users?
I expect that you have a basic understanding of how linux works. This is important on how to configure your jenkins and write the necessary build steps. The most basic information you will find on http://jenkins-ci.org and basic installation https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
How to debug Jenkins issue seen?
That depends ...
... on the issue. If you have build problems check the console output of the job first. In addition, Jenkins writes its logfiles into the jenkins home directory.
How can I instantiate a build by sending an email?
Check out the mail commander plugin

Upload files from linux vps to web host

I want to somehow automatically upload files every 5 minutes. I want to upload/transfer the files from my linux vps to my web host.
What I'm trying to do is upload some logs files generated on my vps to my web host so administrators can access it with an .htaccess file.
use wput along with cron to ftp files to your host
wput [options] [file]... ftp://[username[:password]#]hostname[:port][/[path/][file]]
You will probably have to install the tool as its not included by default (at least it hasnt been on most of my installs)
You'll want to set up a cron job for this. The Wikipedia page for this has a nice overview of how the crontab file is laid out. However, you should check your distribution's documentation for better information (they could be using a different version or a completely different cron daemon).
The line you'd add to the crontab would look something like this:
*/5 * * * * <user to run command as> <your command>
See also: http://www.unixgeeks.org/security/newbie/unix/cron-1.html
Hopefully your web host provides SCP or FTP servers to allow you to copy files over. How do you transfer files when you're uploading your web site files?
If it's ftp, use the ftp command:
ftp -u user:password#host/destination_folder/ sourcefile.txt
If it's scp, use the scp command:
scp foobar.txt username#host:/some/remote/directory

Resources