Sponsored Content
Top Forums Shell Programming and Scripting Run this grep every 10 minutes and do something based on the output Post 302929523 by kraljic on Monday 22nd of December 2014 10:59:42 AM
Old 12-22-2014
Run this grep every 10 minutes and do something based on the output

OS : Red Hat Linux 6.4
Shell : Bash

We have a file called status.txt which will have only 1 line. The content will be the string "Processing" for most of the day.

Code:
# cat status.txt
Processing
#

I want to write a shell script (notify.sh) which will be executing a grep every 10 minutes .

Once the script is executed , it should do the following


1. run a grep command every 10 minutes and check if the content of status.txt is anything other than "Processing" .

2. If the status.txt file has anything other than the string "Processing" (ie. grep -v "Processing" ) then it should echo "Completed". Actually in my real business scenario If the status.txt has anything other than "Processing" then a mail needs to be send out using Linux's mail command. But, for our testing purpose an echo "completed" should do .


3. Stop the execution of the notify.sh script (exit) after grep command managed to find anything other than the string "Processing" and printed "Complete" .

Note: I don't this to be invoked via a cronjob because in my real world scenario this logic has to be incorported as a subsection of a much bigger script. Smilie

Any idea how I can write this piece of code ?
 

10 More Discussions You Might Find Interesting

1. Solaris

Schedule to run every 3 minutes - CRONTAB

Hello all, I want to run a script every 3 minutes in os level and to send mail. I scheduled in crontab as 3 * * * * /mnt1/monitorscripts/testdbstart.sh I got mail every one hour and I confirmed that the script is running every 1 hour which doesn't meet my requirment. Where I am... (4 Replies)
Discussion started by: prashanth_gs
4 Replies

2. Shell Programming and Scripting

Script to run every 5 minutes

Hello all, I want to run a script every 5 minutes. How to accomplish this task? Thanks in advance Mrudula (12 Replies)
Discussion started by: mrudula009
12 Replies

3. UNIX for Dummies Questions & Answers

Run the shell script for every 15 minutes?

I want to run my shell script for every 15 minutes starting from 12:20AM. I am passing parameter GA to shell script. Does this work? Any one please comment on this? 20 0-23/15 * * * xyz.sh 'GA' > xyz.log 2>&1 (9 Replies)
Discussion started by: govindts
9 Replies

4. Shell Programming and Scripting

Read 2 lines from File, Run Command based off output

Okay, so I have a file containing line after line of three digit numbers. I need a script that does an action based on the last two numbers in this list. So.... To get the last two numbers, I can have the script do tail -2 filename.txt But where I run into trouble is as follows. If... (6 Replies)
Discussion started by: UCCCC
6 Replies

5. Shell Programming and Scripting

Run a script continuously for 10 minutes

Hi all!! Im using ksh and my OS is Linux. I want to run a script for ten minutes, starting from my current system time. How to acheive this? Any help appreciated. Thanks in advance (5 Replies)
Discussion started by: Jayaraman
5 Replies

6. Shell Programming and Scripting

Run cronjob for every 10 minutes

Hi Friends, I have a requirement to run the cronjob for every 10 minutes from 2:00 AM to 6:00 AM. Does the below code works? If not, please advise. * * * * * command to be executed ┬ ┬ ┬ ┬ ┬ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └---------------------------------- day of week (0 - 6) (0 is... (5 Replies)
Discussion started by: srikanthbiradar
5 Replies

7. Shell Programming and Scripting

Output block of lines in a file based on grep result

Hi I would appreciate your help with this. I have a output file from a command. It is broken based on initial of the users. Exmaple of iitials MN & SS. Under each section there is information pertaining to the user however each section can have different number of lines. MY challenge is to ... (5 Replies)
Discussion started by: mnassiri
5 Replies

8. Shell Programming and Scripting

Different output based on run method

Sample Data #cat /mylist.txt /raid/job/123 /raid/job/456 /raid/job/789 # Script #cat /myfind.scr #!/bin/bash touch /nojob.txt touch /job.txt unset dirfolder for dirfolder in `/bin/cat /mylist.txt`;do if then echo $dirfolder >>/job.txt else echo $dirfolder >>/nojob.txt (3 Replies)
Discussion started by: crowman
3 Replies

9. Shell Programming and Scripting

Cron Job to Run every 2 minutes

Hello Gurus, I want to schedule a cron job which will run every 2 minutes starts at 11:25 AM and 3:25 AM daily. Can you please suggest as how to schedule the job. Thanks- Pokhraj Das (2 Replies)
Discussion started by: pokhraj_d
2 Replies

10. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies
rhsmcertd(8)					    Subscription Management Certificate Daemon					      rhsmcertd(8)

NAME
rhsmcertd - Periodically scans and updates the entitlement certificates on a registered system. SYNOPSIS
rhsmcertd [--cert-check-interval=MINUTES] [--auto-attach-interval=MINUTES] [--now] [--debug] [--help] Deprecated usage rhsmcertd [certInterval autoattachInterval] DESCRIPTION
Red Hat provides content updates and support by issuing subscriptions for its products. These subscriptions are applied to systems (machines). Red Hat Subscription Manager is a tool which allows administrators to manage those subscriptions by registering systems and people, applying subscriptions, and viewing subscriptions. When subscriptions are applied to a system or when new subscriptions are available, the subscription management system issues that machine an X.509 certificate which contains all of the details of that subscription. The rhsmcertd process runs periodically to check for changes in the subscriptions available to a machine by updating the entitlement certificates installed on the machine and by installing new enti- tlement certificates as they're available. At a defined interval, the process checks with the subscription management service to see if any new subscriptions are available to the system. If there are, it pulls in the associated subscription certificates. If any subscriptions have expired and new subscriptions are available, then the rhsmcertd process will automatically request those subscriptions. This rhsmcertd process invokes the certmgr.py script to perform the certificate add and update operations. Both the certificate interval and the auto-attach interval are configurable and can be reset through the rhsmcertd daemon itself or by editing the Subscription Manager /etc/rhsm/rhsm.conf file. rhsmcertd is started with the machine, by default, and is always running in the background. OPTIONS
-h, --help Prints the specific help information for the given command. -d, --debug Records more verbose output to the /var/log/rhsm/rhsmcertd.log log file. -n, --now Runs the rhsmcertd scan immediately, rather than waiting for the next scheduled interval. -c, --cert-check-interval=MINUTES Resets the interval for checking for new subscription certificates. This value is in minutes. The default is 240, or four hours. This interval is in effect until the daemon restarts, and then the values in the /etc/rhsm/rhsm.conf file are used (unless the argu- ment is passed again). -i, --auto-attach-interval=MINUTES Resets the interval for checking for and replacing expired subscriptions. This value is in minutes. The default is 1440, or 24 hours. This interval is in effect until the daemon restarts, and then the values in the /etc/rhsm/rhsm.conf file are used (unless the argument is passed again). USAGE EXAMPLES
NOTE Be sure to stop the running rhsmcertd daemon before making any configuration changes, or the new configuration is not applied. RESETTING THE CERTIFICATE SCAN INTERVAL service rhsmcertd stop rhsmcertd --cert-check-interval=240 RUNNING CERTIFICATE AND HEALING SCANS IMMEDIATELY Normally, the certificate and auto-attach scans are run periodically, on a schedule defined in the rhsmcertd configuration. The scans can be run immediately -- which is useful if an administrator knows that there are new subscriptions available -- and then the scans resume their schedules. service rhsmcertd stop rhsmcertd -n DEPRECATED USAGE rhsmcertd used to allow the certificate and auto-attach intervals to be reset simply by passing two integers as arguments. rhsmcertd certInterval autoattachInterval For example: service rhsmcertd stop rhsmcertd 180 480 This usage is still allowed, but it is deprecated and not recommended. ASSOCIATED FILES
* /usr/share/rhsm/certmgr.py * /etc/rhsm/rhsm.conf * /var/log/rhsm/rhsmcertd.log BUGS
This daemon is part of Red Hat Subscription Manager. To file bugs against this daemon, go to https://bugzilla.redhat.com, and select Red Hat > Red Hat Enterprise Linux > subscription-manager. AUTHORS
Deon Lackey, <dlackey@redhat.com> and Jeff Ortel, <jortel@redhat.com>. rhsmcertd was written by Jeff Ortel. COPYRIGHT
Copyright (c) 2010-2012 Red Hat, Inc. This is licensed under the GNU General Public License, version 2 (GPLv2). A copy of this license is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. version 1.5 April 30, 2013 rhsmcertd(8)
All times are GMT -4. The time now is 03:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy