Sponsored Content
Top Forums Shell Programming and Scripting Modify Sleeper script to run every 30 minutes Post 302893949 by sea on Saturday 22nd of March 2014 10:17:31 AM
Old 03-22-2014
How about?

Code:
#!/bin/sh
#
#	Author: 	Simon Arjuna Erat (sea)
#	Contact:	erat.simon@gmail.com
#	License:	GNU Lesser General Public License (LGPL)
#	Created:	2014.03.22
#	Changed:	2014.03.24
	script_version=0.2
#	Description:	Trying to 'replace' a single cronjob
#
#	Variables
#
	ME="$(basename $0)"
	minute=60
	hour=$[ 60 * $minute ]
	intervall=$minute
	intervall_anyway=9
	counter=1
	exe_anyway="/production/07a/scripts/dna_monitor/dna_monitor_v1.ksh MAIL_ALWAYS"
	exe_cmd="/production/07a/scripts/dna_monitor/dna_monitor_v1.ksh MAIL_ON_ISSUE"
	job_hour=(3 6 9 11 15 19 23)		# Change for the hours of occourence
	job_minute=(0 10 20 30 40 50)		# Change for the minutes of occourence
	logfile=/var/log/dna_monitor.log
	alias currentHour="date +'%H'"
	alias currentMinute="date +'%M'"
	alias now="date +'%Y.%m.%d - %H:%M'"
#
#	Display & Action
#
	echo "Started $ME ($script_version)..."
	while true;do
		sleep $intervall
		((counter++))
		for ENTRY in ${job_hour[@]};do
			# Check if current hour has a job
			if [ $(currentHour) -eq $ENTRY ]
			then	# Check if current minute has a job
				for ENTRY in ${job_minute[@]};do
					# If job is due, print current date+time to log & execute it
					[ $(currentMinute) -eq $ENTRY ] && \
						printf "$(now) -- EXEC $exe_cmd\n" | tee $logfile && \
						$exe_cmd | tee $logfile 
				done
			fi
		done
		[ $counter -eq $intervall_anyway ] && \
			counter=1 && \
			$exe_anyway
	done

All you need to do is to change the "job_minute=(29 59)"
But me probably 'went off topic'?

hth

Last edited by sea; 03-24-2014 at 02:42 PM..
 

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

Need help howto make a script for Set SNOOP run for 5 minutes

Hi all, I want to monitoring my interface every 6 hours where i want to run snoop command to capture all packet through the interface, so i want running snoop then snoop will run for 5 minutes after that snoop stop then will start again after 6 hours than run for 5 minutes again. thereis any... (9 Replies)
Discussion started by: tindasz
9 Replies

3. 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

4. Shell Programming and Scripting

How to run a script everyday between 7 and 8 pm with the time interval of 5 minutes?

Hi, Can someone help me in running a cronjob everyday between 7 and 8 pm with the time interval of 5 minutes in between to repeat that script. The script is so small and I need that to run daily between this time. Please if possible provide me the syntax for this logic. Thanks. (4 Replies)
Discussion started by: cya
4 Replies

5. 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

6. 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

7. 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

8. Shell Programming and Scripting

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. # cat status.txt Processing #I want to write a shell script (notify.sh) which will be executing a grep every 10 minutes . ... (7 Replies)
Discussion started by: kraljic
7 Replies

9. Shell Programming and Scripting

Cron Job to Run for 30 minutes

Hello Gurus, I have a requirement to run a job from cron only for 30 minutes duration daily twice at 8.35 am and 20.35 pm Can you please suggest how to schedule the job? Thanks- Pokhraj (5 Replies)
Discussion started by: pokhraj_d
5 Replies

10. 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
LEAVE(1)						    BSD General Commands Manual 						  LEAVE(1)

NAME
leave -- remind you when you have to leave SYNOPSIS
leave [[+]hhmm] DESCRIPTION
leave waits until the specified time (within the next 12 hours), then reminds you that you have to leave by writing to the TTY that you exe- cuted leave on. You are reminded 5 minutes and 1 minute before the actual time, at the time, and every minute thereafter. When you log off, leave exits just before it would have printed the next message. OPTIONS
hhmm The time of day is in the form hhmm where hh is a time in hours (on a 12 or 24 hour clock), and mm are minutes. However, all times are converted to a 12 hour clock, and assumed to be in the next 12 hours. An attempt to set an alarm for farther into the future will be truncated to within the next 12 hours. + If the time is preceded by '+', the alarm will go off in hours and minutes from the current time. If no argument is given, leave prompts with "When do you have to leave?". A reply of newline causes leave to exit, otherwise the reply is assumed to be a time. This form is suitable for inclusion in a ~/.login or ~/.profile. SEE ALSO
calendar(1), csh(1), sh(1) HISTORY
The leave command appeared in 3.0BSD. BUGS
In the modern age with X(7) and window multiplexing programs like window(1) and screen(1), the leave command's reminders and admonitions might not be seen if the user has the window where leave was started minimized or obscured. This all begs for a more general user notifications system to be implemented. BSD
January 19, 2002 BSD
All times are GMT -4. The time now is 03:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy