LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-23-2016, 11:44 AM   #1
sub320
Member
 
Registered: Jan 2016
Posts: 40

Rep: Reputation: Disabled
can not run cron job


deleted

Last edited by sub320; 01-26-2016 at 09:17 PM.
 
Old 01-23-2016, 11:54 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,336

Rep: Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896Reputation: 3896
Quote:
Originally Posted by sub320 View Post
I have just created a simple script , if .. then .. , it can not run at shell manually perfectly , but when run on cron job , it can not run , therefore , may I know how to make the script run on shell manually is totally equally to run on cron job ?

Thanks
Read the 'Question Guidelines' and "How to ask a smart question" links in my posting signature. Without details and a clear question, there's nothing anyone can tell you.

You say "simple script"...but don't post it. You also say it can NOT run in the shell, and also say it can not run via cron...sounds like your script is plain broken.

Post your script, details, etc., and we may be able to help.
 
Old 01-23-2016, 11:58 AM   #3
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Xubuntu, Manjaro
Posts: 756
Blog Entries: 3

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by sub320 View Post
I have just created a simple script , if .. then .. , it can not run at shell manually perfectly , but when run on cron job , it can not run , therefore , may I know how to make the script run on shell manually is totally equally to run on cron job ?
Umm... ok. I am guessing here, since your question does not make that much sense to me, that you in fact CAN run the script "manually" in the shell, but NOT as a cron job.

Here are my suggestions:
  1. Show us your script. It is impossible to help you without seeing what you have done.
  2. 99 times out of 100, the problem with cron not "working" is that cron does not share the same $PATH as your shell. Try using full paths to any executables.
  3. Again, show us your script!
 
1 members found this post helpful.
Old 01-23-2016, 08:35 PM   #4
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
deleted

Last edited by sub320; 01-26-2016 at 09:17 PM.
 
Old 01-24-2016, 02:32 AM   #5
sub320
Member
 
Registered: Jan 2016
Posts: 40

Original Poster
Rep: Reputation: Disabled
deleted

Last edited by sub320; 01-26-2016 at 09:17 PM.
 
Old 01-24-2016, 02:57 AM   #6
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Xubuntu, Manjaro
Posts: 756
Blog Entries: 3

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by sub320 View Post
thanks reply ,

"cron does not share the same $PATH as your shell" << == may I know how to do it ?

thanks
Lots to read here: http://stackoverflow.com/questions/2...-correct-paths

Best regards,
HMW
 
Old 01-24-2016, 09:59 AM   #7
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,198
Blog Entries: 4

Rep: Reputation: 131Reputation: 131
Quote:
Originally Posted by sub320 View Post
thanks reply ,

I tested the script , the "pidof slapd | xargs lsof -a -p | wc -l` -gt 1000" could not output the result when run in cron , but work fine to run manually , how to change it to make it work ?

thanks
Post the script and the post the cron job.

Just glancing that the sample code, looks like there might be a syntax error (missing semicolon) with the then keyword.

Code:
if [ `pidof slapd | xargs lsof -a -p | wc -l` -gt 1000  ] ;
then
     /etc/init.d/slapd restart
fi
 
Old 01-24-2016, 10:27 AM   #8
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Xubuntu, Manjaro
Posts: 756
Blog Entries: 3

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by JockVSJock View Post
Just glancing that the sample code, looks like there might be a syntax error (missing semicolon) with the then keyword.

Code:
if [ `pidof slapd | xargs lsof -a -p | wc -l` -gt 1000  ] ;
then
     /etc/init.d/slapd restart
fi
Nope. You don't need a semicolon there:
Code:
$ bar=1
$ if [ $bar -eq 1 ]
> then
> echo $bar
> fi
1
Best regards,
HMW
 
  


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
Debian daily cron job won't run, but does run in cron.hourly. sandersch Linux - General 7 05-24-2012 02:50 AM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 05:00 AM
how to run this cron job ashley75 Linux - General 5 05-24-2004 12:20 PM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 09:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 03:37 PM


All times are GMT -5. The time now is 07:34 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration