Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Nohup error

Solaris


Tags
nohup, solaris 10, unix & linux - unix commands

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-30-2017   -   Original Discussion by phanidhar6039
phanidhar6039's Unix or Linux Image
phanidhar6039 phanidhar6039 is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 1 September 2017, 11:19 AM EDT
Posts: 46
Thanks: 2
Thanked 0 Times in 0 Posts
Nohup error

Hi,

I tried to run a script as a back end process and getting below error for nohup command in solaris10.

Any help will be great.


Code:
server1# nohup (time ./genrep) > genrep.log 2>&1
ksh: syntax error: `(' unexpected

Able to run genrep a standalone but getting error when i try with time using nohup.
Sponsored Links
    #2  
Old Unix and Linux 08-30-2017   -   Original Discussion by phanidhar6039
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 13 December 2017, 10:10 PM EST
Location: San Jose, CA, USA
Posts: 10,774
Thanks: 590
Thanked 3,771 Times in 3,219 Posts
Why are you trying to run the backend process in a sub-shell?

Doesn't the following (without the parentheses) do what you need to do?:

Code:
nohup time ./genrep > genrep.log 2>&1

Sponsored Links
    #3  
Old Unix and Linux 09-01-2017   -   Original Discussion by phanidhar6039
phanidhar6039's Unix or Linux Image
phanidhar6039 phanidhar6039 is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 1 September 2017, 11:19 AM EDT
Posts: 46
Thanks: 2
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Don Cragun View Post
Why are you trying to run the backend process in a sub-shell?

Doesn't the following (without the parentheses) do what you need to do?:

Code:
nohup time ./genrep > genrep.log 2>&1

Thanks Don.

when i execute that and logout the script gets disconnected. Am i missing anything here.

Idea is to execute the script in back end even though i logout my session. so trying to execute as below

Code:
nohup time ./genrep > genrep.log 2>&1 &


Last edited by phanidhar6039; 09-01-2017 at 11:44 AM.. Reason: missed code
    #4  
Old Unix and Linux 09-01-2017   -   Original Discussion by phanidhar6039
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 13 December 2017, 10:16 AM EST
Location: Saskatchewan
Posts: 22,546
Thanks: 1,159
Thanked 4,286 Times in 3,955 Posts
First, time is a shell builtin and likely won't work in that context. You might have to do something like ksh -c "time ./gengrep"

Also, I'm not sure if stdin is redirected.

Also, if you're using ksh, you should disown the process after you background it.

How about:


Code:
nohup ksh -c "./genrep" >/dev/null 2>/dev/null </dev/null & disown

The Following User Says Thank You to Corona688 For This Useful Post:
Don Cragun (09-01-2017)
Sponsored Links
    #5  
Old Unix and Linux 09-01-2017   -   Original Discussion by phanidhar6039
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 13 December 2017, 10:10 PM EST
Location: San Jose, CA, USA
Posts: 10,774
Thanks: 590
Thanked 3,771 Times in 3,219 Posts
Quote:
Originally Posted by Corona688 View Post
First, time is a shell builtin and likely won't work in that context. You might have to do something like ksh -c "time ./gengrep"

Also, I'm not sure if stdin is redirected.

Also, if you're using ksh, you should disown the process after you background it.

How about:


Code:
nohup ksh -c "./genrep" >/dev/null 2>/dev/null </dev/null & disown

In ksh, time isn't just a shell built-in; it's a shell keyword. (I'm sure Corona688 understands the difference, but for other readers who may not, it matters when you want to time a pipeline consisting of more than one process. In a shell where time is a keyword:

Code:
time a | b | c

will give you timing results for the entire pipeline. In a shell were time is a built-in, that command will just give you timing results for the execution of a; not the entire pipeline.) The POSIX standards allow time to be either a keyword or a built-in.

Note also that disown with no operands will disown all active background jobs started by the shell; not just the most recently started background job. If that isn't what you want, you might want to try something more like:

Code:
nohup ksh -c "time ./genrep" < /dev/null > genrep.log 2>&1 & disown $!

The Following User Says Thank You to Don Cragun For This Useful Post:
Corona688 (09-12-2017)
Sponsored Links
    #6  
Old Unix and Linux 09-02-2017   -   Original Discussion by phanidhar6039
jlliagre's Unix or Linux Image
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlos
 
Join Date: Dec 2007
Last Activity: 13 December 2017, 3:12 AM EST
Location: Outside Paris
Posts: 4,876
Thanks: 18
Thanked 637 Times in 556 Posts
Beware that the non POSIX "disown" utility is not available to the OP who is running Solaris 10. "disown" is only implemented in Solaris 11.

In any case, "disown" is not required here, being redundant. The "nohup" call is already disconnecting the launched process from the running session so there is no reason to try to do it twice.
The Following User Says Thank You to jlliagre For This Useful Post:
Corona688 (09-12-2017)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[SOLVED] Error running a script in nohup mode nash83 UNIX for Dummies Questions & Answers 3 03-17-2014 07:14 PM
Saving nohup output to a file other than nohup.out kraljic Shell Programming and Scripting 7 12-08-2013 05:33 PM
Error while running script using nohup vignesh53 Shell Programming and Scripting 2 01-13-2012 10:16 AM
nohup standerd error arvindng Shell Programming and Scripting 5 02-10-2009 12:38 PM
error piping nohup to /dev/null mochi Shell Programming and Scripting 4 03-02-2006 01:32 AM



All times are GMT -4. The time now is 12:05 AM.