LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 06-29-2010, 08:32 PM   #1
hussa1n
LQ Newbie
 
Registered: Jun 2010
Location: India
Distribution: RHEL5, Ubuntu
Posts: 13

Rep: Reputation: 0
Run two commands in same script with a time delay


I have a script which has two commands. One is to kill the process and the second is to start it.
When I run the script while the the process is running the process is being killed but the second command is not being executed.
But when I run the script when the process is not running the second command is executed.

When I kill the process and then start it using the second command after a few seconds it just works fine.

Is there any way to run the 2 commands with a delay of 5-10 seconds?

Is there any other way to solve this issue?
 
Old 06-29-2010, 08:42 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Take a look at the "sleep" command.

Also, show us what your script looks like.
 
1 members found this post helpful.
Old 06-29-2010, 10:42 PM   #3
hussa1n
LQ Newbie
 
Registered: Jun 2010
Location: India
Distribution: RHEL5, Ubuntu
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks pixellany.
I am trying to use this script to kill the vlc process and start it again. It looks something like this
Code:
#!/bin/bash
killall vlc
/sbin/refresh_vlc.sh
How can a sleep command be used in the above script to get a delay of 5-10 seconds between the execution of these two commands
 
Old 06-30-2010, 12:35 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Thumbs up

Quote:
Originally Posted by hussa1n View Post
Thanks pixellany.
I am trying to use this script to kill the vlc process and start it again. It looks something like this
Code:
#!/bin/bash
killall vlc
/sbin/refresh_vlc.sh
How can a sleep command be used in the above script to get a delay of 5-10 seconds between the execution of these two commands
You can use it as

Code:
#!/bin/bash
killall vlc
sleep 10
/sbin/refresh_vlc.sh
Here, 10 is in seconds. You may use whatever value you feel like.
 
1 members found this post helpful.
Old 06-30-2010, 01:04 AM   #5
hussa1n
LQ Newbie
 
Registered: Jun 2010
Location: India
Distribution: RHEL5, Ubuntu
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks for the reply @ vikas027.
I would test it and post the outcome of it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script - I want some time delay between each command is executed bbmak Linux - Newbie 2 12-21-2007 03:35 AM
Run one script, but execute commands at the same time Micro420 Programming 8 07-18-2007 12:05 AM
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM
I need to run commands every time I want my wireless card to work... sloik2000 Linux - Wireless Networking 4 12-17-2006 11:29 AM
run 2 commands in a script ddpicard Linux - General 10 06-13-2003 04:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 02:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration