Sponsored Content
Top Forums Shell Programming and Scripting Help with delaying script and implementing checks before completion Post 302999353 by RudiC on Sunday 18th of June 2017 06:47:53 AM
Old 06-18-2017
Either method is possible; I'd prefer the second with apcaccess as it describes the actual status of the UPS while the log could be delayed / overwritten / have other, meaningless lines. You also seem to have it in your script but commented out. Unfortunately, I don't know apcaccess and so can't tell which info indicates a "power out" status and maybe more (mayhap on top of "STATUS: ONLINE", one of the bits in STATFLAG might give deeper insight?).
Assuming it were the STATUS line, and stealing from your script, try (untested, and not sure the sh shell will correctly run this, you may need e.g. bash)
Code:
sleep 10
/sbin/apcaccess status > /tmp/TMP$$
! grep -q "STATUS   : ONLINE" /tmp/TMP$$ && echo mail -s $MSG  $SYSADMIN </tmp/TMP$$
rm /tmp/TMP$$

Remove the echo when happy with the result.


Final comment: the "shebang" in your script #!/bin/sh needs to be in the very first line to become effective, i.e. determines the shell to be run to execute your code.

Last edited by RudiC; 06-18-2017 at 08:48 AM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script that checks for previous instances running

Hello, I'm trying to write a script that checks for previous instances of the same script which may still be running (this script is scheduled to run every 30 minutes). I want to somehow use the pid from each instance to make sure the previous one isn't running before continuing with my... (5 Replies)
Discussion started by: bd_joy
5 Replies

2. Solaris

Sendmail error delaying relay

When I try to send mail, sendmail delays a lot. After monitoring syslog, I noticed that sendmail starts with this first message... waits a minute and gives the second message... waits another minute and then sends off the email. How do I correct this in sendmail or completly disable it. I'm sending... (0 Replies)
Discussion started by: adelsin
0 Replies

3. Shell Programming and Scripting

Script to perform record format checks

Hi All, I have a requirement to perform the following checks. Input file is a "|" delimited file and looks like this. A|c1|c2|c3|.... B|G1|G2|G3.... C|H1|H2|H3... A|c4|c5|c6|.... B|G4|G5|G6.... C|H4|H5|H6... Now the check is to see if all the "A" records have a corresponding B... (7 Replies)
Discussion started by: gsjdrr
7 Replies

4. Shell Programming and Scripting

Perl script that checks against Future time

Ok, so this may be an unusual request. But I have a certificate that expires sometime in may of 2011. Now, i have to monitor this certificate and alert when the current time is within 30 days of may 20, 2011. #!/usr/bin/perl # use Time::Local; # $sec=59; $min=59; $hours=23; $day=31;... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

[Bash] MD5 Checks with Script.

Hi. I'm triyng to make a Bash Script that checks (recursively) the MD5 from all the files in a certain directory and compare them against some other check that should be already done and saved in a file. I've reached to the point where i have the MD5 from the file and the MD5 that the script... (1 Reply)
Discussion started by: BiFo
1 Replies

6. Shell Programming and Scripting

Script to performs checks

Hi , I need a script which performs below activity I have one file named "testfile" in 9 different directories with same name. I want to perform below action with each testfile of each directory. if ; then mv listfiles listfiles_`date +%b%y` else echo No Such files fi ... (4 Replies)
Discussion started by: sv0081493
4 Replies

7. Shell Programming and Scripting

Script to do the following checks

Hi , I need a script for processing below scenario. I have to check daily by doing ftp IP to check it is logging or not. So i want this activity to be automated such that if login succesful i will get "FTP LOGIN SUCCESS" in a log file and if fails i want the error message in the same log... (1 Reply)
Discussion started by: sv0081493
1 Replies

8. Shell Programming and Scripting

Help with implementing available memory status script

hi , i want write the script which automatically send an alert mail to my mail id when there is low memory available. things which i am able to implement -: i got the output of current memory status into one file . Than i break down the required coloumn and again send it in another file. My... (1 Reply)
Discussion started by: abhinav dixit
1 Replies

9. Shell Programming and Scripting

Script function which checks if itself is already running

Hi All, I have a cron job set up which is set to run every 10 seconds. What I need to do is have the script do a check to see if it is already running such that if it is running it wont fire up additional instances and processes according to its normal process. For example if I have a script... (4 Replies)
Discussion started by: landossa
4 Replies

10. Solaris

Sendmail delaying mails for 45 mins

Hi, I'm trying to send out mails from my server using mailx, however everytime I send one, it appears to be held in the /var/spool/mqueue for 44 mins before being sent. I'm quite new to sendmail, so don't really know where to start with this /var/log/syslog displays the following: Dec 16... (4 Replies)
Discussion started by: badoshi
4 Replies
OPTIUPS(8)							    NUT Manual								OPTIUPS(8)

NAME
optiups - Driver for Opti-UPS (Viewsonic) UPS and Zinto D (ONLINE-USV) equipment NOTE
This man page only documents the hardware-specific features of the optiups driver. For information about the core driver, see nutupsdrv(8). SUPPORTED HARDWARE
optiups was originally written against a PowerES 280es in nut-0.45. It was revised for nut-2.0.1 and tested against a PowerES 420E. It is expected to work with at least the PowerES, PowerPS, and PowerVS models. This driver additionally supports a Zinto D from ONLINE USV-Systeme AG because of their very similar commands, but it is unknown if it also works with other UPS from them. This driver will not work with the PowerES stock serial cable. You will need to construct your own three conductor cable: UPS 6 -> PC 3 UPS 9 -> PC 2 UPS 4 -> PC 5 The cable for Online-USV uses pin UPS 7 (not UPS 4) -> PC 5. EXTRA ARGUMENTS
This driver supports the following optional settings in the ups.conf(5) file: status_only Only poll for critical status information. Without this, optiups (and all NUT drivers) poll all sorts of information from the UPS fairly often. It is probably not often enough to hurt anything, so this option probably is not very useful, unless you have a flaky serial connection or a highly loaded machine. nowarn_noimp Does not print warnings when the UPS reports that a variable is not implemented or not pollable. Without the option you will get a message sent to your system logs each time NUT polls the UPS. If you specify nowarn_noimp, this message will only be logged once. fake_lowbatt This forces the low battery flag true. Without it, if you want to test your UPS, you will have to unplug it and wait until the battery drops to a low/critical voltage level before NUT will respond and power down your system. With the flag, NUT should power down the system soon after you pull the plug. When you are done testing, you should remove this flag. For basic shutdown configuration testing, the command upsmon -c fsd is preferred. powerup Zinto D from ONLINE-USV cannot be identified when switched to standby. Set this flag to allow the driver to power-up your Zinto UPS. This will also power-up your equipment connected to the UPS! BUGS
On the 420E, ups.serial and ups.temperature are unsupported features. This is not a bug in NUT or the NUT driver, just the way things are with this UPS. AUTHOR
Russell Kroll, Scott Heavner, Matthias Goebl SEE ALSO
The core driver: nutupsdrv(8) Internet resources: The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ Network UPS Tools 05/21/2012 OPTIUPS(8)
All times are GMT -4. The time now is 01:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy