- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Running a shell script continuously after exiting ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:21 PM
01-10-2006 03:21 PM
i am runnig a shell script test1.sh and recording its out in a file test2. I used the command $./test1.sh >>test2 &
But when i exited xterm session (login session) the script stopped. I wanted to run it continuously even if i logged out. How to do it ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:26 PM
01-10-2006 03:26 PM
Re: Running a shell script continuously after exiting the login session
because u r running it off as a job at the background, either u do not exit/logoff or setup as a cron job.
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:28 PM
01-10-2006 03:28 PM
Re: Running a shell script continuously after exiting the login session
use nohup. It will continue to operate, even when u close your session. It will send the output to the file name nohup.out. Even you can specify your own file, where the output can be stored.
EX:
nohup test1.sh &
HTH,
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:32 PM
01-10-2006 03:32 PM
Re: Running a shell script continuously after exiting the login session
"nohup" is the command that will help you.
nohup - run a command immune to hangups
You can run as,
$ nohup ./test1.sh >>test2 &
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:33 PM
01-10-2006 03:33 PM
Re: Running a shell script continuously after exiting the login session
You can avoid that by starting with su as,
# su -
Example:
# cat /tmp/muthu/test1.sh
echo "script is started"
sleep 10
echo "script is end"
hostname
ls -l
# su - root -c "/tmp/muthu/test1.sh 1>/tmp/muthu/test.log 2>&1 &"
it is working after log out too.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:38 PM
01-10-2006 03:38 PM
Re: Running a shell script continuously after exiting the login session
You can see more information at,
http://www.computerhope.com/unix/unohup.htm
http://www.livefirelabs.com/unix_tip_trick_shell_script/june_2003/06022003.htm
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:41 PM
01-10-2006 03:41 PM
Re: Running a shell script continuously after exiting the login session
nohup is another way to achive it. It is like it will execute the process until it is getting completed.
Su is like it will create another process which will not be controlled by currently logged shell.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:55 PM
01-10-2006 03:55 PM
Re: Running a shell script continuously after exiting the login session
And it is not advised to use "SU" while running a script. It may lead to a security lapse..:-)
--
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 03:59 PM
01-10-2006 03:59 PM
Re: Running a shell script continuously after exiting the login session
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2006 04:03 PM
01-10-2006 04:03 PM
Re: Running a shell script continuously after exiting the login session
If you are running as a same user then it is not a problem to do right? :)
Like
user -> su to same user.
It is a thought to reach the destination. Dream yourself to get more ways. Don't using same way always ;)
==
Shiv,
Simple way is to use nohup. You can go with su or as well as telnet + piping() program too.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2006 08:04 PM
01-11-2006 08:04 PM
Re: Running a shell script continuously after exiting the login session
you have to use nohup:
nohup ./test1.sh >>test2 2>&1 &
I suggest you to redircet the stderr (2) to the stdout (1) otherwise you will find it in the nohup.out file.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2006 12:56 AM
01-12-2006 12:56 AM
Re: Running a shell script continuously after exiting the login session
I would also use the fully qualified path when using nohup.
$nohup /dir/dir/test1.sh >>test2 2>&1 &