Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-29-2014, 10:38 PM
|
#1
|
LQ Newbie
Registered: Jan 2013
Posts: 3
Rep: 
|
Cron is being mean :(
Hey Guys,
This is the most frustrating problem I've had in a while. I have an Elastix PBX running on CentOS 5.10. Everything works perfectly - except this Cron job:
*/1 * * * * /var/www/html/calls.sh
here's the script:
#! /bin/sh
file="/var/www/html/calls.txt"
if [ -f "$file" ]
then
rm /var/www/html/calls.txt
touch /var/www/html/calls.txt
chmod 777 /var/www/html/calls.txt
asterisk -rx 'core show channels' | grep -m1 "call" | cut -d' ' -f1 >> /var/www/html/calls.txt
else
touch /var/www/html/calls.txt
chmod 777 /var/www/html/calls.txt
asterisk -rx 'core show channels' | grep -m1 "call" | cut -d' ' -f1 >> /var/www/html/calls.txt
fi
When I run this manually in a terminal, it does exactly what I want it to - however, when Cron runs it, it will create the calls.txt file, but it does not write anything to it. The server only has one user (root) and when I created this, I created it as root.
Can someone help?
Thanks!
|
|
|
07-29-2014, 11:39 PM
|
#2
|
LQ Newbie
Registered: Jan 2013
Posts: 3
Original Poster
Rep: 
|
Nevermind - Specifying the path fixed this:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
|
|
|
07-30-2014, 12:04 AM
|
#3
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,676
|
so please mark the thread solved. The problem was I think the cron job cannot find the command asterisk. You ought to use all the commands using full path in cronjobs.
|
|
|
07-30-2014, 01:09 AM
|
#4
|
Senior Member
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,071
Rep:
|
I think the problem is that cron 'ignores' all ENV variables.
|
|
|
07-30-2014, 02:12 AM
|
#5
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,676
|
No that is not a problem at all. It is designed to do that.
|
|
|
07-31-2014, 12:34 AM
|
#6
|
Senior Member
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,071
Rep:
|
so its a design flaw. :P
|
|
|
07-31-2014, 12:41 AM
|
#7
|
Moderator
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,389
|
Quote:
Originally Posted by qrange
so its a design flaw. :P
|
No, it is a design constraint.
|
|
|
All times are GMT -5. The time now is 04:39 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|