How to write a shell script for nohup command with redirection ?


In this post, I will teach you a few things to run any executable file in Linux in the background using redirection. I have specified the steps with examples as mentioned below:

STEPS:


1. Create a sample file (eg: )
  • command : vi <file1>.sh
  • example : vi startadmin.sh

2. Add the following lines and save the file :
  • command : nohup ./<PATH>/<execution_file>.sh >> /<PATH>/file1.out 2>&1 &
  • example : nohup ./home/oracle/bin/startWebLogic.sh >> /home/oracle/AdminServer.out 2>&1 &

3. Give the permission to the newly created file
  • command : chmod 775 <file1>.sh
  • example : chmod 775 startadmin.sh

This method can be used to run file such as starting Admin Server in Weblogic example, startWebLogic.sh.
But be sure to follow the below guidelines to ensure this trick works.
  1. define the correct path of the execution file and the out file.
  2. give the appropriate permission
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© Ganesh Sairam's Oracle Blog
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0
Posts RSSComments RSS
Back to top