how to open application and after some time(time delay) automatically it should close
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how to open application and after some time(time delay) automatically it should close
firefox | kill -9 `ps -A | grep firefox`
while using above command firefox opening and immediately it getting closed instead of that i need delay between opening and closing of application,i have alreay tried below command:
firefox | sleep 5 | kill -9 `ps -A | grep firefox`
while using above command firefox opening and immediately it getting closed instead of that i need delay between opening and closing of application,i have alreay tried below command:
firefox | sleep 5 | kill -9 `ps -A | grep firefox`
What are you trying to accomplish with this? You're starting firefox, and wanting it to run for only 5 seconds before killing it?? What is the point/goal? And you can just put the commands in a shell-script, and execute them, if that's really what you want:
Why do you need to "kill -9"? A simple kill should work and will allow the process to terminate cleanly (save existing state, etc.) rather than just terminating it abruptly. It might be best to make sure you get the correct firefox PID, just in case there are multiple copies running (e.g. using different user accounts. A generic script to do this would be something like:
Code:
#!/bin/bash
progtorun=$1
progtorun &
progpid=$!
sleep 30 # replace 30 with number of seconds to sleep
kill $progpid
sleep 5 # give it some time to die
kill -9 $progpid >& /dev/null # make sure it's dead.
Edit to add: you could make this script more robust by adding alarm signals in conjunction with wait to trap and see if the child process exits before the timer runs out. See this page for the basic idea.
Last edited by btmiller; 05-27-2013 at 02:39 PM.
Reason: more info
What are you trying to accomplish with this? You're starting firefox, and wanting it to run for only 5 seconds before killing it?? What is the point/goal? And you can just put the commands in a shell-script, and execute them, if that's really what you want:
Code:
firefox &
sleep 5
kill -9 `ps -A | grep firefox`
Santosh :just i want to write script which opens one application after another,but during that process first application should close before next application opens,hence i asked this question,anyway thanks your answer resolved my problem
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.