LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   can not run cron job (https://www.linuxquestions.org/questions/linux-newbie-8/can-not-run-cron-job-4175567725/)

sub320 01-23-2016 10:44 AM

can not run cron job
 
deleted

TB0ne 01-23-2016 10:54 AM

Quote:

Originally Posted by sub320 (Post 5486281)
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.

HMW 01-23-2016 10:58 AM

Quote:

Originally Posted by sub320 (Post 5486281)
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!

sub320 01-23-2016 07:35 PM

deleted

sub320 01-24-2016 01:32 AM

deleted

HMW 01-24-2016 01:57 AM

Quote:

Originally Posted by sub320 (Post 5486544)
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

JockVSJock 01-24-2016 08:59 AM

Quote:

Originally Posted by sub320 (Post 5486468)
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


HMW 01-24-2016 09:27 AM

Quote:

Originally Posted by JockVSJock (Post 5486659)
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


All times are GMT -5. The time now is 06:15 AM.