Visit Our UNIX and Linux User Community


Add the flag


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add the flag
# 1  
Old 06-19-2010
Add the flag

Code:
#!/bin/bash
while :
do
./abc.sh PB
sleep 60
./abc.sh RA
sleep 60
./abc.sh GS
sleep 68400
done


Instead of making the script sleep for sometime, it doesn't work all the time as time may shift over a period.
How to make a script wake up every 30 seconds and check the current time, if the time is around 01:01:00 for the
./abc.sh PB then execute the script. When the check is done, how to mark it the flag as completed.
At 12:00AM reset all the flags and how to check again for the next day.
# 2  
Old 06-19-2010
use cron

1. edit the script to add:
Code:
. /etc/profile
. ~/.profile

This makes the environment in cron match what you have interactively.

use crontab -e and add this
Code:
1 1 * * * /home/me/myscript.sh 2&>1 > /home/me/myscript.log

# 3  
Old 06-20-2010
Hi,

I do not want to use crontab

Code:
#!/bin/bash
while :
do
# Add wait until time is curdate 01:01:00
./abc.sh PB
#Wait until time is curdat 01:01:54
./abc.sh RA
#Wait until time is curdat 01:02:04
./abc.sh GS
#Wait until time is curdat 01:05:00
#Execute again from ./abc.sh PB checking the curtime,
done



---------- Post updated 06-20-10 at 08:09 AM ---------- Previous update was 06-19-10 at 11:11 PM ----------

Code:
#!/bin/bash
time=$(date +"%H:%M:%S")

while :
do
flag=0
until [ $time = '05:47:00' ]
do
echo "1st loop"
flag=1
done
until [ $time = '05:48:00' ]
do
echo "2nd loop"
done
done


How to add the conditional check for time at every step and if time is as mentioned and execute the script and move to nect step if the flag is 1.
At the end move to the first step and again wait until time is '05:47:00' and execute for the next day.

---------- Post updated at 08:43 AM ---------- Previous update was at 08:09 AM ----------

Code:
flag=0
time=$(date +"%H:%M:%S")
while :
do

while :
do
if [ $(date +"%H:%M:%S") = '06:30:00' ]
then
echo "1st loop"
fi
flag=1
done

while :
do
if [$flag = 1 ]
then
if [ $(date +"%H:%M:%S") = '06:31:00' ]
then
echo "2nd loop"
fi
fi

done
done

I have added the condition, while loop is added until it satisfies the first condition. There is repeated times on echo "1st loop" statement printed. So if the condition is true then, I have to exit that loop and go to next loop, so that only once the echo is printed.

Last edited by sandy1028; 06-20-2010 at 10:52 AM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #97
Difficulty: Easy
Unix is a multi-user operating system where the same resources can be shared by different users even if they do not have the proper permissions to do so.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Get the id with specify flag

.... means multi line ddd,bug fgdrg dfdfsdfdfsd fsdfdfdfd fdfdsfdsfsd ....... flag2 ...... aaa,bug sfsfsfsfs dfdfsdfdfsd fsdfdfdfd fdfdsfdsfsd ...... flag1 ...... ddd,bug fgdrg dfdfsdfdfsd (9 Replies)
Discussion started by: yanglei_fage
9 Replies

2. Shell Programming and Scripting

Flag duplicate enteries

Morning Unix Guru's, I have written a script which output the contents of a DB. No the DB is not clever to check this or flag and there is no command for the tool to flag this, which human intervention. But i need to check to see if there are duplicate enteries in the file output and flag... (5 Replies)
Discussion started by: Junes
5 Replies

3. UNIX for Dummies Questions & Answers

'h' flag in du

Hey, all! Why is the "human readable" flag changing the behavior of du? And while I'm at it, can you make du only look at files, not directories. I often find myself wanting to find the largest file(s) in a dir or vol. Using 'find' itself, it seems you have to at least be able to guess the size of... (2 Replies)
Discussion started by: sudon't
2 Replies

4. AIX

Flag issue

Hi all, We dont have access to aix source code and i have a doubt. The flag SC_NO_RESERVE, is it got to do anything with the failover? If the flag is set the paths are going to failed state. If flag is not set everything comes up fine after failover. Thanks in advance for helping ... (2 Replies)
Discussion started by: gnakul
2 Replies

5. AIX

du flag -x

Hi, I would like to know if there's any option to use with the du command so that I can list only the files/directories on the current filesystem... I usually use du -gs *But I'd like to see only the directories in the filesystem I am on, and not the mount point directory of other fss... ... (6 Replies)
Discussion started by: Casey
6 Replies

6. Shell Programming and Scripting

Date Time of FLAG

Hi, I am first sorry to ask for that, but I am in trouble so I hope you will be agreed to help me on this. I am solaris (ksh). I have a lots of file but I only need to get the date and time of the flag files. Here is the "ls -lrt" view : ls -lrt | grep Flag_Saturne_R*Return ... (3 Replies)
Discussion started by: Aswex
3 Replies

7. Red Hat

-ansi flag support for g++

I have been compiling a cpp program using following command: g++ -c -ansi a.cpp with g++ version 4.1.2. I want to know the significance of the -ansi flag and which other higher g++ version supports this flag by default Dhiraj (1 Reply)
Discussion started by: dhiraj kurhade
1 Replies

8. AIX

Checking for flag in a subscript?

I want to incorportae a subscript in a job script which is used for loading purposes. What i require is that before a job runs it should check for a flag ,if flag is not present then create it and the loading should start. Once loading finishes it should delete the flag. So if any other load... (1 Reply)
Discussion started by: bathla
1 Replies

9. Shell Programming and Scripting

the flag -c in sh command

I need your help please. In a production system, i've seen many running process as follow: sh -c ./pathname/shellname what exactly the flag option -c is used for? ive tried to look at the man page, but it doesnt say much. ill appreciate yor help. Thanks (4 Replies)
Discussion started by: alexcol
4 Replies

10. UNIX for Dummies Questions & Answers

mailx Issue with -r flag

I've used "mailx -r return@address" before many times for automated scripts, but when I try to use it on FreeBSD, I get "mailx: illegal option -- r". Is there another version of mailx I should be using to get this to work? The full command I'm trying to run is: mailx -s "Load Results $(date... (1 Reply)
Discussion started by: superdelic
1 Replies

Featured Tech Videos