Sponsored Content
Top Forums Shell Programming and Scripting Inotifywait restart script prevents reboot when started Post 303038350 by Peasant on Saturday 31st of August 2019 04:20:00 AM
Old 08-31-2019
Here is a quick bash mockup, using md5sum without inotify tools.
Where myapp.sh is being executed.

Kill is regular not dash 9, if you really need to use that signal, change it..
It will not check if myapp.sh was started by hand outside script tho.

Of course, additional error handling could be implemented..

Code:
#!/usr/bin/bash

CONFDIR="/workdir/rst"
MYAPP="$CONFDIR/myapp.sh"
CSUM="$CONFDIR/config2.md5"
CONFFILE="$CONFDIR/config2.txt"
# Check interval in seconds
CHECKINT=5

cleanapp () {
  kill $CURPID
}

startapp () {

if [ -z $CURPID ]
then 
	$MYAPP & CURPID=$!
	md5sum $CONFFILE > $CSUM
else
	md5sum -c $CSUM
		if [ $? -gt 0 ]; then
			kill $CURPID
			$MYAPP & CURPID=$!
			md5sum $CONFFILE > $CSUM
		fi
fi

}
	
trap "cleanapp" 0

while true ; do

	startapp
	sleep $CHECKINT
	# Check if MYAPP is on process list, if not clear CURPID so it can be started again
	ps -p $CURPID || CURPID="" 
done

Hope that helps
Regards
Peasant.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need some help getting started on this script

Hi. I am just getting into scripting. I came into a situation where I need to go through several hundred files on a Linux system and find a couple specific bits of information from within each file. All the files have pretty much identical content except for a view data values on the same two lines... (4 Replies)
Discussion started by: Dave247
4 Replies

2. AIX

xntpd starts after reboot only when HACMP services are started ?

Hello, Running AIX 6.1, AIX machine is HACMP node. Recently I set up ntp service. Started xntpd by hand - everythig is OK. Configured xntpd to start after reboot and rebooted the machine. After reboot checked xntpd: # lssrc -a|grep ntp xntpd tcpip ... (5 Replies)
Discussion started by: vilius
5 Replies

3. Shell Programming and Scripting

inotifywait to wait until completion

Hi, I am using inotifywait to monitor a directory where files are being transferred into. I want inotifywait to tell me when a file has been completely transferred not just part of it. I tried "create", "close" and "close_write" but it seems that inotifywait always gets triggered even if the... (4 Replies)
Discussion started by: jejeking
4 Replies

4. Shell Programming and Scripting

Script using inotifywait

Is there a way to get my script to only trigger when a .ppt is created? #!/bin/bash while inotifywait -e create /ticker/powerpointshare; do sleep 30; sudo chmod -R 777 /ticker/powerpointshare/*.*; sleep 15; sudo reboot; done I'm not sure if this is even possible... (0 Replies)
Discussion started by: binary-ninja
0 Replies

5. Shell Programming and Scripting

Inotifywait tool in no there in Redhat 5.6

Hi, I want to monitor any new file to be created in some of the directory using inotifywait tool but this is not available in Redhat 5.6. Could you please let me know how to achieve (monitoring of file) without using inotifywait too? Because i dnt want to install this tool due to some reason.... (1 Reply)
Discussion started by: Pawan Kumar
1 Replies

6. Shell Programming and Scripting

Help with my BASH script with WINE and inotifywait

I'm trying to improve a script that I have running on a Ubuntu desktop that basically runs a powerpoint presentaions with announcements to TV's in diffrent parts of our building. My current script uses WINE to execute powerpoint viewer. The scripts that I currently use relies on inotifywait's... (1 Reply)
Discussion started by: binary-ninja
1 Replies

7. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

8. Shell Programming and Scripting

Piping through grep/awk prevents file write

So, this is weird... I'm running this command: iotop -o -P -k -bt -d 5 I'd like to save the output relelvant to rsyslogd to a file, so I do this: iotop -o -P -k -bt -d 5 | grep rsyslogd >> /var/log/rsyslogd Nothing is written to the file! I can write the full output to the file: ... (2 Replies)
Discussion started by: treesloth
2 Replies

9. Shell Programming and Scripting

Sed: deleting last line prevents '$' address from working in the multi-script invocation

It looks like if matching and deleting the last line confuses 'sed' so it does not recognize '$' address. Consider: sed -e '/^3/d' -e '$ a text' supposed to delete a line starting with '3' and then append 'text' after the last line of input. But, if it is the last line of input which starts... (2 Replies)
Discussion started by: msz59
2 Replies

10. Solaris

Changing "rx_queue_number" in "ixgbe.conf". Reboot or Network Restart?

Hi all, First post here. Working on Solaris 10, on a Sun t4-4, need to change RX queue depth(ethernet, not HBA) and was wondering if i could get by with just restarting the network or if i should just bounce the whole shebang. Apologies if i missed a similar thread. if there is one, please... (2 Replies)
Discussion started by: caspnx
2 Replies
gst-md5sum-0.8(1)						   User Commands						 gst-md5sum-0.8(1)

NAME
gst-md5sum-0.8, gst-md5sum - get an md5sum of a GStreamer pipeline through md5sink SYNOPSIS
gst-md5sum-0.8 [--verbose] [gst-std-options] [partial-pipeline-description] gst-md5sum [--verbose] [gst-std-options] [partial-pipeline-description] [--gst-list-mm] [--gst-mm=string] [--print] DESCRIPTION
gst-md5sum-0.8 generates MD5 checksums of the data generated by a GStreamer pipeline. In theory, both of the following commands should print out the same checksum: gst-md5sum-0.8 filesrc location=music.mp3 md5sum music.mp3 If the pipeline contains an md5sink element, gst-md5sum-0.8 queries it for the md5sum at the end of pipeline iteration. If the pipeline does not contain an md5sink element, gst-md5sum-0.8 automatically connects an md5sink to the right-hand side of the given pipeline. See gst-launch(1) or the GStreamer documentation for more information on how to create a partial-pipeline-description. gst-md5sum is a wrapper script that runs the latest installed version of gst-md5sum-X.X. For example, if both gst-md5sum-0.7 and gst- md5sum-0.8 are installed on your system, gst-md5sum runs gst-md5sum-0.8. OPTIONS
The following options are supported by gst-md5sum-0.8 and gst-md5sum: --verbose Output verbose information. You can also use -v to specify this option. gst-std-options Standard options available for use with most GStreamer applications. See gst-std-options(5) for more information. The following options are supported by gst-md5sum only: --gst-list-mm List found major/minor versions. This option displays the versions that are available. --gst-mm=string Force major/minor version. This option enables you to specify a specific version to run, if you do not want to run the default version. --print Print wrapped command line. This option displays the command that will be run, and then runs the command. OPERANDS
The following operands are supported: partial-pipelinePartialppipeline description. EXAMPLES
Example 1: Running the Wrapper Script and Displaying the Command Name example% gst-md5sum --print /usr/bin/gst-md5sum-0.8 FILES
The following files are used by this application: /usr/bin/gst-md5sum-0.8 Executable for GNOME help browser /usr/bin/gst-md5sum Wrapper script that runs the latest installed version of gst-md5sum-X.X ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-media | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
gst-complete(1), gst-compprep(1), gst-feedback(1), gst-inspect(1), gst-launch(1), gst-launch-ext(1), gst-register(1), gst-thumbnail(1), gst-typefind(1), gst-xmlinspect(1), gst-xmllaunch(1), gstreamer-properties(1), libgstreamer-0.8(3), libgstgetbits(3), gst-std-options(5) NOTES
Original man page written by the GStreamer team at http://gstreamer.net/. Updated by Brian Cameron, Sun Microsystems Inc., 2004. SunOS 5.10 14 Oct 2004 gst-md5sum-0.8(1)
All times are GMT -4. The time now is 03:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy