Welcome to the North American Subaru Impreza Owners Club Tuesday March 19, 2024
Home Forums Images WikiNASIOC Products Store Modifications Upgrade Garage
NASIOC
Go Back   NASIOC > NASIOC Miscellaneous > Off-Topic

Welcome to NASIOC - The world's largest online community for Subaru enthusiasts!
Welcome to the NASIOC.com Subaru forum.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, free of charge, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, so please join our community today!

If you have any problems with the registration process or your account login, please contact us.







* As an Amazon Associate I earn from qualifying purchases. 
* Registered users of the site do not see these ads. 
Reply
 
Thread Tools Display Modes
Old 01-28-2005, 02:50 PM   #1
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default UNIX dudes - help with nohup

I have some processes I'm going to be kicking off that'll take a couple of hours to run, and I'd rather not be logged in to run them. So I tried this:

nohup ./somescript.sh -someflag -param1 /path/to/file.xml -param2 /path/to/bla.log &

It starts, directing output to "nohup.out", but immediately stops, and the only thing in nohup.out is "somescript.sh: bad substitution".

Thinking something was wrong with using args like that, I tried writing another script that basically just contains the above call, and tried this:

nohup ./dumbscript.sh &

But, same problem, bad substitution in nohup.out, only this time it says "dumbscript.sh" has the problem.

Any idears? Usually Google Groups has solutions to all things relating to error messages, but I'm not having any luck.
* Registered users of the site do not see these ads.

Last edited by TimStevens; 01-28-2005 at 02:57 PM.
TimStevens is offline   Reply With Quote
Sponsored Links
* Registered users of the site do not see these ads.
Old 01-28-2005, 02:53 PM   #2
Hypernoodle
Scooby Specialist
 
Member#: 12391
Join Date: Nov 2001
Chapter/Region: NESIC
Location: YER.MOMS.A.HAIKU.AND.HERES.WHY
Vehicle:
I did her 5 times
then 7 times, then 5 more

Default

I know this might sound dumb, but try passing the full path for the script and see if that does it.
Hypernoodle is offline   Reply With Quote
Old 01-28-2005, 02:56 PM   #3
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

i was actually using ./, which I forgot to type above, but I'll try that.

In the dumbscript.sh I did use the full path to the other script.
TimStevens is offline   Reply With Quote
Old 01-28-2005, 03:14 PM   #4
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Hrm, no dice. Same error.

I just discovered you can use nohup -p to control a process that's already running, so maybe I'll just kick the app off, get the PID, and do it that way.

Would love to know what the problem is, though, if anyone has any ideas.
TimStevens is offline   Reply With Quote
Old 01-28-2005, 03:23 PM   #5
Hypernoodle
Scooby Specialist
 
Member#: 12391
Join Date: Nov 2001
Chapter/Region: NESIC
Location: YER.MOMS.A.HAIKU.AND.HERES.WHY
Vehicle:
I did her 5 times
then 7 times, then 5 more

Default

Quote:
Originally Posted by TimStevens
Hrm, no dice. Same error.

I just discovered you can use nohup -p to control a process that's already running, so maybe I'll just kick the app off, get the PID, and do it that way.

Would love to know what the problem is, though, if anyone has any ideas.
Okay...

Instead of calling the script directly, preface the full script path with the "sh" command.

nohup sh ./somescript.sh -someflag -param1 /path/to/file.xml -param2 /path/to/bla.log &
Hypernoodle is offline   Reply With Quote
Old 01-28-2005, 03:32 PM   #6
kbcr3
Scooby Specialist
 
Member#: 44170
Join Date: Sep 2003
Chapter/Region: Tri-State
Location: Arlington, VA
Vehicle:
2010 Forester XT
05 and 09 honda ruckus

Default

can you just run it in cron later in the day or night?
kbcr3 is offline   Reply With Quote
Old 01-28-2005, 03:40 PM   #7
bigdweeb
Scooby Specialist
 
Member#: 31035
Join Date: Dec 2002
Chapter/Region: NESIC
Location: Boston
Vehicle:
10 Mazda Miata
21 CWP Outback XT

Default

why not just run screen, start the process and detatch the screen session. Then reattach later to check progress.
bigdweeb is offline   Reply With Quote
Old 01-28-2005, 03:46 PM   #8
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Quote:
Originally Posted by bigdweeb
why not just run screen, start the process and detatch the screen session. Then reattach later to check progress.
You mean Ctrl-Z and bg and fg? These don't work if you log off.

I can't really cron this stuff, since I don't know how long each process will take, and I need to run each in sequence, but need to verify the previous run was successful before kicking the next one off (it's essentially a batch load of data to the DB, the script calls a process to load it). So, I need to start them manually.

I'll try the sh option. My understanding was you only needed that if your files weren't set as executable.
TimStevens is offline   Reply With Quote
Old 01-28-2005, 03:49 PM   #9
bigdweeb
Scooby Specialist
 
Member#: 31035
Join Date: Dec 2002
Chapter/Region: NESIC
Location: Boston
Vehicle:
10 Mazda Miata
21 CWP Outback XT

Default

Quote:
Originally Posted by TimStevens
You mean Ctrl-Z and bg and fg? These don't work if you log off.

I can't really cron this stuff, since I don't know how long each process will take, and I need to run each in sequence, but need to verify the previous run was successful before kicking the next one off (it's essentially a batch load of data to the DB, the script calls a process to load it). So, I need to start them manually.

I'll try the sh option. My understanding was you only needed that if your files weren't set as executable.
no, not what I meant... screen is a process that you can run. I allows you to run a shell and then disconnect from it, but you can leave stuff running still. When you want to check up on things you reconnect to the machine and then reattach to the screen session as if you never left.
bigdweeb is offline   Reply With Quote
Old 01-28-2005, 05:31 PM   #10
Kartoffel
Scooby Specialist
 
Member#: 12976
Join Date: Dec 2001
Chapter/Region: TXIC
Location: Huntsville, Alabamy
Vehicle:
2002 WRX
grocery getter

Default

Yes. screen will get the task done nicely.
Kartoffel is offline   Reply With Quote
Old 01-28-2005, 07:10 PM   #11
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

I've never used screen before, but from the manpage it sounds like it needs a windows manager..? Unfortunately I'm running these commands on a machine I only have telnet access to.
TimStevens is offline   Reply With Quote
Old 01-28-2005, 07:46 PM   #12
Kartoffel
Scooby Specialist
 
Member#: 12976
Join Date: Dec 2001
Chapter/Region: TXIC
Location: Huntsville, Alabamy
Vehicle:
2002 WRX
grocery getter

Default

Quote:
Originally Posted by TimStevens
sounds like it needs a windows manager..?
The "window" is simply your tty. Just play with it locally to get a feel for it.

Once you're logged in, start a screen with
Code:
screen
Start your job(s)
Code:
stuff blah etc
Then detatch screen with ctrl-a, ctrl-d. You are free to log out.

When you log back in later, reattach to screen with
Code:
screen -r
and you'll pick back up right where you left off. Awesome, huh? Screen is good stuff.

You can also use screen to mux two ttys together, so that two users can see the same thing. First user starts screen with `screen' as usual, the second user does `screen -x' to attach to the existing screen. Now, whatever one user types will appear on the other's tty. This is handy for interactively helping n00bs or for collaborative editting, etc.
Kartoffel is offline   Reply With Quote
Old 01-28-2005, 07:56 PM   #13
sct
Scooby Newbie
 
Member#: 20644
Join Date: Jun 2002
Chapter/Region: TXIC
Location: Austin, TX
Default

Quote:
Originally Posted by Kartoffel
Then detatch screen with ctrl-a, ctrl-d. You are free to log out.
Good overview post. The one point I have is that on my boxes it is just "CTRL-A d".

I am using it all weekend to do some server migration. Certiainly one of the most useful tools to a sysadmin or batch processor there is.
sct is offline   Reply With Quote
Old 01-28-2005, 08:14 PM   #14
linux>windows
*** Banned ***
 
Member#: 49517
Join Date: Nov 2003
Chapter/Region: MWSOC
Location: Downtown Grand Rapids, MI
Default

Still need help?
linux>windows is offline   Reply With Quote
Old 01-28-2005, 09:26 PM   #15
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Nice, thanks guys. Appreciate the help. I'll give that a shot when I'm back to work on monday
TimStevens is offline   Reply With Quote
Old 01-28-2005, 09:56 PM   #16
linux>windows
*** Banned ***
 
Member#: 49517
Join Date: Nov 2003
Chapter/Region: MWSOC
Location: Downtown Grand Rapids, MI
Default

oh, good luck..
linux>windows is offline   Reply With Quote
Old 01-29-2005, 12:36 AM   #17
Kartoffel
Scooby Specialist
 
Member#: 12976
Join Date: Dec 2001
Chapter/Region: TXIC
Location: Huntsville, Alabamy
Vehicle:
2002 WRX
grocery getter

Default

Quote:
Originally Posted by TimStevens
Nice, thanks guys. Appreciate the help. I'll give that a shot when I'm back to work on monday
yay for weekends
Kartoffel is offline   Reply With Quote
Old 01-29-2005, 03:59 AM   #18
sct
Scooby Newbie
 
Member#: 20644
Join Date: Jun 2002
Chapter/Region: TXIC
Location: Austin, TX
Default

Weekends are nice. I only have to work part time. Thank the lord I am salary. Oh wait, that isn't so special.
sct is offline   Reply With Quote
Old 01-29-2005, 08:28 AM   #19
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Quote:
Originally Posted by Kartoffel
yay for weekends
Yeah, seriously, it's been a bit of a long week. I'd log in and try it out now, but I'll probably be doing some work over next weekend, so I'll take this weekend to chill out
TimStevens is offline   Reply With Quote
Old 02-17-2005, 02:41 PM   #20
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Thought I'd give this a bump since I finally had time to get back to this.

screen looks like it'd work perfectly, but unfortunately it's a GNU package and the admin won't install anything on there unless there's a system need. I'm sure he'd dig it if he tried it, but alas, it's not going on there.

But, I got nohup to work. Turns out I made a stupid mistake on the script I was calling, forgot the #!/bin/bash at the beginning of the script. Put that in and nohup works fine. Much more clunky than screen sounds, but not much I can do aboot that.

Thanks for the assistance guys.
TimStevens is offline   Reply With Quote
Old 02-17-2005, 03:08 PM   #21
aod
Scooby Newbie
 
Member#: 7121
Join Date: Jun 2001
Chapter/Region: MWSOC
Location: D2F.1 = D2F.2, D2F.3 = D2F.4
Default

I missed this thread somehow. You should be able to run a process in the background and detach your tty without it killing the process as well. Nohup is not really necessary anymore with shells that have job control. Nohup was necessary back in the days of shells without job control. You can background a process by putting an & at the end of the command line. You should be able to logout at that point and the process will not receive a HUP (Hang UP) signal, hence no need for nohup. Of course, being a programmer I'm sure you are familiar with signal trapping. If you wanted to go a step further just to make sure, you could make your process ignore HUP signals.
aod is offline   Reply With Quote
Old 02-17-2005, 03:11 PM   #22
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Well, it's a Java app, so I'd imagine that's up to what the JVM does with it, and I don't know honestly. It's worth trying, though... after the first batch job completes... which should be sometime tomorrow morning
TimStevens is offline   Reply With Quote
Old 02-17-2005, 03:13 PM   #23
aod
Scooby Newbie
 
Member#: 7121
Join Date: Jun 2001
Chapter/Region: MWSOC
Location: D2F.1 = D2F.2, D2F.3 = D2F.4
Default

Quote:
Originally Posted by TimStevens
Well, it's a Java app, so I'd imagine that's up to what the JVM does with it, and I don't know honestly. It's worth trying, though... after the first batch job completes... which should be sometime tomorrow morning
Is it just running through jre? If so, you should be able to background it no problem.
aod is offline   Reply With Quote
Old 02-17-2005, 03:14 PM   #24
TimStevens
Scooby Specialist
 
Member#: 4817
Join Date: Mar 2001
Chapter/Region: NESIC
Location: Albanyish, NY
Default

Yep, the 1.4.2 JVM running on Solaris 8.
TimStevens is offline   Reply With Quote
Old 02-17-2005, 03:16 PM   #25
moktod
Scooby Newbie
 
Member#: 34768
Join Date: Apr 2003
Location: i am everywhere
Vehicle:
2002 Impreza WRX
White

Default

install 'screen'

use it

love it

never look back

-moktod

p.s.

let me know when you have it installed and I will give you my quick howto.
moktod is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with something truenosan Vancouver Impreza Club Forum -- VIC 7 06-02-2010 09:05 PM
Help with greasing up the bushings kmper02 Newbies & FAQs 1 06-02-2010 03:52 PM
Java/J2EE dudes - help me with a DataSource problem re92 Off-Topic 1 03-01-2005 06:36 PM
Need help with some UNIX commands. Kinsbane Off-Topic 9 04-05-2004 11:51 PM
please help with unix PhantomOG Texas Impreza Club Forum -- TXIC 17 10-20-2001 10:11 AM

All times are GMT -4. The time now is 01:35 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Powered by Searchlight © 2024 Axivo Inc.
Copyright ©1999 - 2019, North American Subaru Impreza Owners Club, Inc.

As an Amazon Associate I earn from qualifying purchases.

When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission
Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.