Sponsored Content
Top Forums Shell Programming and Scripting Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box Post 302925384 by whizkidash on Monday 17th of November 2014 01:09:44 AM
Old 11-17-2014
Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team,

Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is mentioned/specified as Total Transaction(column)and users are mentioned as List of users(column).
Currently there are 100 users(different names) and the count is 100

below is the main script details

Code:
FILEDATE=`date +%F`
LOGFILE=/home/xyz/scripts/myscript.$FILEDATE.log
find /home/xyz/scripts/myscript.*.log -type f -mtime -3 -delete
touch $LOGFILE
exec 1>$LOGFILE 2>&1
for ip_addr in $(cat /home/xyz/scripts/ip_remote);do
echo "###logged into $ip_addr### "
ssh ${ip_addr} "bash -s" < /home/xyz/scripts/hourly_details
echo "###logged out  $ip_addr###"
done
cat /home/xyz/scripts/myscript.$FILEDATE.log | mailx -s "Hourly active users" <ur email id>

the ip_remote consist of the remote ip address its going to login
the hourly_details consist of below

Code:
sudo su - abc
sh active.sh

Basically, I am looking to execute the script hourly on my jump-box but to notify me only when any of the users(List of users) are down and as per its count(Total Transactions).
Is there any way around ?

Regards
Whizkid

Last edited by Don Cragun; 11-17-2014 at 02:20 AM.. Reason: Fix CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run expect script in systems that don't support it out of box

Noob question .. My Java based application needs to change some user passwords based on some user actions. Since this application can run on Redhat AS2.1 / AS4.0 / Solaris 9 etc, the most safe and portable solution that I could think of was: Use expect. Now, expect is not available on all... (1 Reply)
Discussion started by: namityadav
1 Replies

2. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies

3. Shell Programming and Scripting

Box A's perl script calling box B's shell script

Hi all, i have a perl script one server. I am running a cronjob to execute my perl script. #! /usr/bin/perl ... ... ... #call a shell script on another server How can i accomplish #? Do i have to issue a system (" ssh -l username server | shellscript.sh") in my shell script? or is there a... (1 Reply)
Discussion started by: new2ss
1 Replies

4. Shell Programming and Scripting

calling a unix script in one box from another box

i have a unix script which is available in a box say box1 i want this script to be run in box box2 and put the output file in box2 what is the procedure to execute this script in box2 i will call the script in box1 using cybermation (1 Reply)
Discussion started by: trichyselva
1 Replies

5. Linux

Local shell script need to be executed on a remote linux box

I need to execute a shell script on a remote linux box. But the shell script resides on the local linux box where I am currently logged in. Is there a way to do this? I know rsh <host> <command> can execute a command on the remote host. (6 Replies)
Discussion started by: rajeshomallur
6 Replies

6. UNIX for Dummies Questions & Answers

Mail on a box failure : Autosys

I need to send invoke a script that sends out a mail, whenever a box fails (i.e., one or more of the jobs in the box fail). The key point is that this job should start on failure of box, but it should be able to find out the jobs in the box that have failed and pass them to the script. Please... (1 Reply)
Discussion started by: hidnana
1 Replies

7. Shell Programming and Scripting

ftp file starting with particular name on Windows box to Unix box using shell script

Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the... (2 Replies)
Discussion started by: vijayb4u83
2 Replies

8. Linux

How to find remote Linux box login account without login in to that box?

Hi, How to find remote Linux box login account without login in to that box? I don't have login account at my remote Linux box. But I need who are all having login account. How do I findout? Thanks, --Muthu. (3 Replies)
Discussion started by: Muthuselvan
3 Replies

9. How to Post in the The UNIX and Linux Forums

Copying , renaming the file from windox box and ftp to Linux box

Hello my dear friends, Two file are auto generated from mon - fri at different directories on same windows box.Every day i have to copy the file, rename it (specific name)and ftp it to linux box specified directory. is it possible to automate this process,If yes this has to be done from windows... (1 Reply)
Discussion started by: umesh yadav
1 Replies

10. Programming

Remote login UNIX box from java passing parameters to the custom script called in the profile

Hello Good Day / Guten Tag.... I have to login the server and the user profile contains some scripts which need the inputs to be taken from the keyboard. So I use the method to conn.authenticateWithKeyboardInteractive(username, new InteractiveCallback() { public String... (1 Reply)
Discussion started by: Sanalkumaran
1 Replies
LAST,LASTB(1)						Linux System Administrator's Manual					     LAST,LASTB(1)

NAME
last, lastb - show listing of last logged in users SYNOPSIS
last [-R] [-num] [ -n num ] [-adFiowx] [ -f file ] [ -t YYYYMMDDHHMMSS ] [name...] [tty...] lastb [-R] [-num] [ -n num ] [ -f file ] [-adFiowx] [name...] [tty...] DESCRIPTION
Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty's can be given, in which case last will show only those entries matching the arguments. Names of ttys can be abbreviated, thus last 0 is the same as last tty0. When last catches a SIGINT signal (generated by the interrupt key, usually control-C) or a SIGQUIT signal (generated by the quit key, usu- ally control-), last will show how far it has searched through the file; in the case of the SIGINT signal last will then terminate. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since the log file was created. Lastb is the same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad login attempts. OPTIONS
-f file Tells last to use a specific file instead of /var/log/wtmp. -num This is a count telling last how many lines to show. -n num The same. -t YYYYMMDDHHMMSS Display the state of logins as of the specified time. This is useful, e.g., to determine easily who was logged in at a particular time -- specify that time with -t and look for "still logged in". -R Suppresses the display of the hostname field. -a Display the hostname in the last column. Useful in combination with the next flag. -d For non-local logins, Linux stores not only the host name of the remote host but its IP number as well. This option translates the IP number back into a hostname. -F Print full login and logout times and dates. -i This option is like -d in that it displays the IP number of the remote host, but it displays the IP number in numbers-and-dots nota- tion. -o Read an old-type wtmp file (written by linux-libc5 applications). -w Display full user and domain names in the output. -x Display the system shutdown entries and run level changes. NOTES
The files wtmp and btmp might not be found. The system only logs information in these files if they are present. This is a local configura- tion issue. If you want the files to be used, they can be created with a simple touch(1) command (for example, touch /var/log/wtmp). FILES
/var/log/wtmp /var/log/btmp AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl SEE ALSO
shutdown(8), login(1), init(8) Jul 31, 2004 LAST,LASTB(1)
All times are GMT -4. The time now is 09:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy