Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Execution problem with Cron


View Poll Results: Was this post useful?
yes 1 100.00%
no 0 0%
Voters: 1. This poll is closed

Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Execution problem with Cron

Hi,
I'm unable to understand why the grep command in cronjob works intermittently

Expected output:
Grep command to look for a particular string with today's date and exit from infinite while loop else it must sleep for 5 mins

I'm using the following statement in my shell script, the variable $logString is empty even when the pattern exists in the log
Code:
while [ -z "$logString" ]
                do
                        echo "Sleep for 5 mins" >> $LOG
                        sleep 300
                        # logString=$(/usr/bin/perl -ne '/STATUS\s+\['"$month"'\/'"$day"'\s+(05|06).*\]\:\s+main\:\s+Active\s+region.*/ && print' << logname>>)
                        logString=$(grep "$(/usr/bin/date +"\%m/\%d")" /ilx/log/exrMngr.log | /usr/bin/grep ".*0[56]\:[0-9]\{2\}\:[0-9]\{2\}" | /usr/bin/grep 'Active region has been')
                        echo "String is: $logString" >> $LOG
                done

while it was successful in yesterday's cron run

Sleep for 5 mins
String is: STATUS [06/09 05:04:57]: main: Active region has been changed from: 0 to: 1

it failed today

Sleep for 5 mins
String is:

Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 2 Weeks Ago at 08:40 AM..
# 2  
Three things we need to help:
Code:
1 What UNIX?
2. What shell?
3. a sample of the log file that you know has the pattern.  A few lines are great.

Otherwise we are just guessing what is going on. Thanks.
# 3  
1 What UNIX?
- SunOS 11.4.5
2. What shell? -
- /bin/sh
3. a sample of the log file that you know has the pattern. A few lines are great.
Code:
             - STATUS [06/10 05:05:01]: Total counts of security records: 8982673.
               STATUS [06/10 05:05:02]: main: Active region has been changed from: 1 to: 0
               STATUS [06/10 05:06:02]: elapsed time: 60; vait_time: 1800

Cronjob starts at 5, ideally it should have exit at 05:05:02 when it finds the matching string


Snap from the cronjob log
Code:
============ Started at Sun Jun  9 05:00:00 EDT 2019 ==========
Put to maintenance
Sleep for 5 mins
String is: STATUS [06/09 05:04:57]: main: Active region has been changed from: 0 to: 1
Flush_cache.sh Completed
Taking the process out of maintenance


Last edited by vbe; 1 Week Ago at 06:53 AM..
# 5  
Well, I can't see an error / failure. No "intermittend" behaviour. Data is from 10. June, and log (which seems to have worked) from 9. June. They can't possibly match.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Execution problem with CRON job
vipin kumar rai
HI, I have written an executable file in unix and I was able to execute it successfully but when I called this file with cron job it was giving error like "permission denied" and "No such file or directory". Please help in how cron calls the file and what permission is required on the file...... Shell Programming and Scripting
2
Shell Programming and Scripting
Execution problem with Cron: Script works manually but not w/Cron. Why?
okonita
Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2...... UNIX for Dummies Questions & Answers
3
UNIX for Dummies Questions & Answers
problem with sleep cmd in execution of cron...
manoj424
I am scheduling a task at regular intervals at seconds acuracy using crond and sleep command . my data in crontab file is as below:- the above line is working fine when we are creating this crontab file before 00:05 min . But when we are creating the crontab file at 00:05min , unable to...... Shell Programming and Scripting
10
Shell Programming and Scripting
Execution Problem with Cron
vibhar
Guys, I am beginer in unix. There is a cobol file with fixed-width. I want to read the total Line, Word and character count. I have tried with wc-l unix command, but it returns '0'. Please advice me the correct command/steps to get the record count. Thanks in advance.... AIX
4
AIX
Solaris 10.5 perl and cron job execution problem
sonu2die4
Hi, I want to run a crontab job on solaris 10.5. I have configured the crontab accordingly 10 * * * * /scripts/dbalter.pl >> /scripts/cronout.txt However this does not work .Then I go to /var/mail/root and find an error in the output: From root@myserver Wed Feb 4 17:02:00 2009...... Solaris
1
Solaris

Featured Tech Videos