SUPER simple bash script to repeat a command...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SUPER simple bash script to repeat a command...
# 1  
Old 03-22-2009
SUPER simple bash script to repeat a command...

I need to repeat this command on a configurable interval:

igal -a -r -U -w 6

I tried this:
Code:
#!/bin/bash

igal -a -r -U -w 6

sleep 30

Just a guess that it MIGHT work.

Can anyone point me in the right direction?

-R
# 2  
Old 03-22-2009
A quick way would be using an infinite loop ...

Code:
#!/bin/bash

while :
 
 do

   igal -a -r -U -w 6

   sleep 30

 done

# 3  
Old 03-22-2009

Code:
period=${1:-60} ## default to every 60 seconds
while :
do
  sleep $period &
  igal -a -r -U -w 6
  wait
done

Or, put an entry in your contab file.

Or, if you have the watch command:

Code:
watch -n "$period"  igal -a -r -U -w 6

etc., etc., etc....
# 4  
Old 03-22-2009
Quote:
Originally Posted by cfajohnson

Code:
period=${1:-60} ## default to every 60 seconds
while :
do
  sleep $period &
  igal -a -r -U -w 6
  wait
done

Or, put an entry in your contab file.

Or, if you have the watch command:

Code:
watch -n "$period"  igal -a -r -U -w 6

etc., etc., etc....
WATCH!!!! i was trying to remember that buggerin thing! Though writing a script is good learnin....

Thanks guys!

-Rob
# 5  
Old 03-23-2009
Quote:
Originally Posted by cfajohnson

Code:
period=${1:-60} ## default to every 60 seconds
while :
do
  sleep $period &
  igal -a -r -U -w 6
  wait
done

Or, put an entry in your contab file.

Or, if you have the watch command:

Code:
watch -n "$period"  igal -a -r -U -w 6

etc., etc., etc....
Using the watch command, is there a way to echo the output to a logfile?

I run root-tail on my desktop and would like to see the result show up their.

Generically speaking, what is the bash script syntax that will echo any output that normally wouldn't be displayed--I know it's broad and vague, sorry.

Lastly, does anyone know which logfile has the unix/linux system main console? If I'm not mistaken doesn't every application echo something somewhere? E.g. when you launch say firefox from the bash prompt you all kinds of output, isn't this and all aps echo some kind of content to a "core" log file?

Thanks!

-Rob
# 6  
Old 03-23-2009
Quote:
Originally Posted by robfindlay
Using the watch command, is there a way to echo the output to a logfile?

Code:
watch <your comand> | tee logfile

Quote:
I run root-tail on my desktop and would like to see the result show up their.

Generically speaking, what is the bash script syntax that will echo any output that normally wouldn't be displayed--I know it's broad and vague, sorry.

If there's output, it will be displayed unless you (or the application) redirect the output somewhere else, or if there's no controlling terminal.
Quote:
Lastly, does anyone know which logfile has the unix/linux system main console?

Check the files in /var/log/ and the dmesg command
Quote:
If I'm not mistaken doesn't every application echo something somewhere?

No.
Quote:
E.g. when you launch say firefox from the bash prompt you all kinds of output, isn't this and all aps echo some kind of content to a "core" log file?

No.
# 7  
Old 03-23-2009
Quote:
Originally Posted by cfajohnson

Code:
watch <your comand> | tee logfile


If there's output, it will be displayed unless you (or the application) redirect the output somewhere else, or if there's no controlling terminal.

Check the files in /var/log/ and the dmesg command

No.

No.

Thank you!! I forgot how much of a newb I am :-(
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Super Simple Script to remove first characters of any png file

Well I searched the net with varying success, but it seems kinda hard to find a one/max 2 lined command to: strip all *.png files in the folder from their first two characters. Any help is appreciated. In DOS commandline of course... (17 Replies)
Discussion started by: pasc
17 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. UNIX for Dummies Questions & Answers

Another Simple BASH command I don't understand. Help?

I have a text file called file1 which contains the text: "ls -l" When I enter this command: bash < file1 > file1 file1 gets erased. However if I enter this command: bash < file1 > newfile the output from "ls -l" is stored in newfile. My question is why doesn't file1's text ("ls -l") get... (3 Replies)
Discussion started by: phunkypants
3 Replies

4. UNIX for Dummies Questions & Answers

Help understanding a simple command in BASH

This is the command. Assume file1 exists but file2 does not: ls file1 file2 >newfile 2>&1 This simply makes a text file with two lines: file1 \n file2 could not be found. What I don't understand is that when you run this command: ls file1 file2 >newfile, it prints "file2 could not be found" to... (1 Reply)
Discussion started by: phunkypants
1 Replies

5. Shell Programming and Scripting

Simple bash script help

Hi to everyone here, I'm a new user and relatively-new linuxer. I'm trying to write a script that checks if every file from a directory is present in a given list and if not, delete it. should be simple. But I think I've done half the work only: this is to create the reference list: for c... (2 Replies)
Discussion started by: dentex
2 Replies

6. Shell Programming and Scripting

need a simple bash script

to gather the cpu utilization from a system in 5 minute intervals and direct output to file. I'm new at scripting and while this seems like an easy task I'm confused on where to start. thanks for any help (1 Reply)
Discussion started by: mkeyes001
1 Replies

7. Shell Programming and Scripting

simple bash script permission

I have a bash script, but it needs to have a simple protection with password. So if a user wants to run the script , there should be a kdialog to asks for a password.If the password is correct the script starts to run. It should not be the passord of root or another admin user.Just a password in... (2 Replies)
Discussion started by: poort
2 Replies

8. Shell Programming and Scripting

simple bash script

I am writing a shell script in bash one of the thing I want to show is size of export /home du -sk /export/home/oracle | cut -c 1-5 echo "kbytes" when I run the script kbytes shows up in the second line, How can I append kbytes on the same line, such as 61233 kbytes please guide thanks (2 Replies)
Discussion started by: Tirmazi
2 Replies

9. Shell Programming and Scripting

Simple BASH script?

Hi guys, I'm new to the forum so forgive me if I'm sounding ... daft. I currently work in a Tech Support role. Every day we have to generate data by running around 10 .sh scripts. I was thinking instead of having to ./filename 10 times is it possible to right a new script that will run these for... (16 Replies)
Discussion started by: JayC89
16 Replies

10. Shell Programming and Scripting

Simple Bash Script

I'm sure I'm doing something wrong but as I am new to bash shell scripting I'm not sure what: Here's the code webalizer.conf is sitting in the same directory as this file which is named webalizer.sh. Can someone tell me if I've got the syntax right -- it that's correct? I'm executing the... (3 Replies)
Discussion started by: xaphalanx
3 Replies
Login or Register to Ask a Question