cron - "is a directory" error - cron

I am running a cron job on my hosting like
/usr/lib/php -q /home/name/public_html/runscript.php
the email alert says
/bin/sh: /usr/lib/php: is a directory
I am not sure if this is an error with the cron statement or not. I can't find much online.
Any help much appreciated.

You probably want to use /usr/bin/php instead.

Related

VtigerCRM 7.0, scheduler don't work

Hello to everyone and thank you in advance,
I am in a company that has started using the vtigerCRM 7.0 open source on Linux and as we worked out the creation of the workflows to send emails and so on we set the scheduler to run crons for the workflows every 15 minutes, but it never runs. Is there anything we can do to make the scheduler work?
Kind Regards,
Dimitris
First step is to check cron setup.
Using crontab -e you will find the details of cron job.
You should define the cron as below:
* * * * * {Full path of vtiger directory/cron/vtigercron.sh >/dev/null 2>&1
Once you define the workflow you can test the workflow by calling cron file directly as below:
http://{crm url}/vtigercron.php
Make sure than you have set the 775 permission to cron folders and their files.
Hope this will help you.

Linux error - setterm: $TERM is not defined. /etc/cron.hourly/mcelog.cron:

I'm in RHEL 5.9 and using mcelog-0.9pre-1.32.el5, and I get this error hourly on my mail from the /etc/cron.hourly/mcelog.cron,
Could someone help to solve this, when I type echo $TERM, it returns xterm.
thanks,
I expect a very simple solution: Your cron job has no terminal. So how should it use setterm for it? From your mail you should receive also the job/process/script name which runs into trouble. Have a look which one it is and fix it, if really needed.

Cron Logging Issue

I cannot find documentation on how to set up Cron commands for some reason. Here's my current Cron command using GoDaddy's cron job manager tool. It runs twice an hour.
/web/cgi-bin/php5 "$HOME/~path-to-file~/my-function.php" > "$HOME/~path-to-file~/my-function.log"
What I'd like to do is get a thorough log of each time the Cron runs - output, timestamp, etc. I'm trying to debug this script and I'm stuck without some kind of error logging.
Thanks all!
You are directing Standard Output to the specified file by >, but Standard Error gets sent into oblivion. Add 2>&1 to the end of the command to append any errors to the same file.
/web/cgi-bin/php5 /path/to/php > /path/to/logfile.log 2>&1

Cron job mysteriously stopped running?

I have a cron job on an Ubuntu 10.4 server that stopped running for no apparent reason. (The job ran for months and has not been changed.) I am not a *nix guru so I plead ignorance if this is a simple problem. I can't find any reason or indication why this job would have stopped. I've restarted the server without success. Here's the job:
# m h dom mon dow command
0 * * * * java -jar /home/mydir/myjar.jar >>/home/mydir/crontaboutput.txt
The last line in the output file shows that the program ran on 8/29/2012. Nothing after that.
Any ideas where to look?
There should be something in your system log when the job was run. The other thing you could >try is to add 2>&1 to the job to see any errors in your text file. – Lars Kotthoff yesterday
This proved to be the key piece of information - adding 2>&1 allowed me to capture an error that wasn't getting reported anywhere else. The completed command line then looked like:
java -jar /home/mydir/myjar.jar 2>&1 >>/home/mydir/crontaboutput.txt
Perhaps your cron daemon has stopped, or changed configuration (i.e. /etc/cron.deny). I suggest to make a shell script, and running it from crontab. I also suggest to run thru your crontab some other program (just for testing) at some other time. You can use the logger command in your shell script for syslog. Look into system log files.
Accepted answer is correct, (i.e, check the error logs) which pointed out the error in my case. Besides check for the following issues
include('../my_dir/my_file.php) may work from url but it will not work when cron job is run, will spit out error.
$_SERVER variables does not work inside cron os if you are using $_SERVER['DOCUMENT_ROOT'], it will not be recognized and you will have an error in the cron job.
Make sure to test the cron and have it run, send an email etc to make sure it is run.

Cron job from cpanel.. no success

I tried a lot of methods but ended up with nothing in hand..My simple target is to reset a variable to zero at the end of the day.
i checked the location of php as "which php" and "whereis php"
which resulted into /usr/bin/php
here are some of things i tried..
/usr/local/bin/php -f /home/USERNAME/public_html/developer3/crons/filename.php
/usr/bin/php -f /home/USERNAME/public_html/developer3/crons/filename.php
php -q /home/USERNAME/public_html/developer3/crons/filaname.php
/usr/bin/wget -O http://subdomain.sitename.com/crons/filename.php
for quick results, i kept the timming as every minute to execute the code. i could successfully execute the code as
http://subdomain.sitename.com/crons/filename.php
please guide me.
If the path to php on your system is /usr/bin/php then the command you should be running with cron should be
/usr/bin/php /full/path/to/php/script.php
Is the script you're running designed to be invoked from the php-cli in that way? If it isn't and works correctly when you use a browser then you can use curl, if it's installed on your server
curl -A cron-job http://subdomain.sitename.com/crons/filename.php
It would likely be helpful in any event to configure the MAILTO variable (since you're using cPanel, it's just a text box on the appropriate page that you can fill in) so that you get an email with the output from your cron jobs. Having the output emailed to you will help you diagnose what's causing your script to not have the desired effect when it runs.

Resources