LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 08-31-2017, 11:30 AM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,575

Rep: Reputation: 249Reputation: 249Reputation: 249
Executable not found when run as crontab job


I zip up a set of files every hour and compare them with the previous hour's. When I run the script from the command line it works. When I run it in crontab it reports that it can't find /usr/local/bin/zipcmp, but it's there and I specify the path.

Oddly I had a similar problem with another script I run from crontab, but in that case it complained that it didn't find it in $HOME/bin, even though I specified the correct actual path. I 'solved' that problem by linking it into $HOME/bin. I suspected that the problem there was the file, home-made, originally resided in my home/bin directory, but after I made it available to all users and moved it into /usr/local/bin and rewrote the script the cron daemon didn't read the new version.
 
Old 08-31-2017, 12:03 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by RandomTroll View Post
I zip up a set of files every hour and compare them with the previous hour's. When I run the script from the command line it works. When I run it in crontab it reports that it can't find /usr/local/bin/zipcmp, but it's there and I specify the path.
Can you post the exact error message?

As what user are you running this command as and can you post the output of the following commands:
Code:
crontab -l
ls -al /usr/local/bin/zipcmp
Quote:
Oddly I had a similar problem with another script I run from crontab, but in that case it complained that it didn't find it in $HOME/bin, even though I specified the correct actual path. I 'solved' that problem by linking it into $HOME/bin. I suspected that the problem there was the file, home-made, originally resided in my home/bin directory, but after I made it available to all users and moved it into /usr/local/bin and rewrote the script the cron daemon didn't read the new version.
Sounds like the script itself was looking to be found in $HOME/bin and not crontab.
 
Old 08-31-2017, 01:04 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 21,608

Rep: Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168Reputation: 4168
I've never had a problem running a script from crontab using its absolute path but without details there is not much to go on.

Are you running using a users or system wide cron job. Is the command calling the script from the cron job contain just the /path/script or does it have any command line parameters that might contain cron special characters?

Are you using any programs or access files within the script that may not be in the path environment. You can always add a path statement as well as use the absolute path
 
Old 09-01-2017, 12:46 PM   #4
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,575

Original Poster
Rep: Reputation: 249Reputation: 249Reputation: 249
Quote:
Originally Posted by lazydog View Post
Can you post the exact error message?
Quote:
/root/bin/CompareHtaccess: line 8: /usr/local/bin/zipcmp: No such file or directory
Quote:
Originally Posted by lazydog View Post
As what user are you running this command as
root

Quote:
Originally Posted by lazydog View Post
can you post the output of the following commands:
Code:
crontab -l
ls -al /usr/local/bin/zipcmp
-rwxr-xr-x 1 root root 39084 Aug 30 08:12 /usr/local/bin/zipcmp*

I won't list the crontab file.


Quote:
Originally Posted by lazydog View Post
Sounds like the script itself was looking to be found in $HOME/bin and not crontab.
Yes, but I changed the script from $HOME/bin/ThatProgram to /usr/local/bin/ThatProgram . I can make sense of this if cron has cached the file. The server stays up for months at a time.
 
Old 09-01-2017, 01:36 PM   #5
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Quote:
Originally Posted by RandomTroll View Post
I won't list the crontab file.
Yeah, I would not expect you to list the whole crontab just the entry for this script.

Quote:
Yes, but I changed the script from $HOME/bin/ThatProgram to /usr/local/bin/ThatProgram . I can make sense of this if cron has cached the file. The server stays up for months at a time.
So anywhere within ThatProgram do you have the directory listed? That is about the only thing I can think of right now as to why it's not running because it is checking it's working directory and seeing that it hasn't been start form where it thinks it should be.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to run a job as a different user from crontab digitallyamar Linux - Server 2 09-13-2009 06:39 AM
how to run crontab job for every 5 seconds vamsi_k Linux - Newbie 1 09-03-2008 11:31 AM
the crontab job is not run ust Linux - Software 1 03-24-2008 07:03 PM
Run crontab job sunhui Linux - Software 2 05-16-2007 08:35 PM
how to run crontab job every 20 seconds houssamfarag Mandriva 4 06-23-2006 02:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration