Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Background Shell Script Problem
2009-11-02, 09:17 AM
Post: #1
Background Shell Script Problem
We have a few scripts that need to work in the background, and we are noticing that once the starting terminal exits, so does the shell script. I tried to invoke it with nohup, but that exists without an error and doesn't put the script in the background.

Here is a test script:
$ cat testbgp
#!/bin/ksh
trap 'echo error at line $LINENO' ERR

while [ 1 ]
do
echo "This is a background process at `date ' %Y-%m-%d %H:%M:%S'`" >> bgout 2>&1
sleep 5
done

When you exit out from the "Korn Shell" window that started the script (./testbgp 2>bg_out &) then it will stop and the contents of the bg_out file shows:
./testbgp[8]: too many files open in shell

If I don't have anything going to stdout or stderr (even if it is redirected), it will work. We have a few scripts that do something similar to this that we use to test our products. This works fine on all our Unix systems, but SUA causes a problem for us. Is there a known workaround?

Thanks,

Tom


[TomLaptop]: unikix; uname -X

System = Interix
Node = TomLaptop
Release = 6.0
Version = 10.0.6030.0
Machine = genuineintel
Processor = Intel64_Family_6_Model_15_Stepping_6
HostSystem = Windows
HostRelease = 6.0
HostVersion = SP2
Find all posts by this user
Quote this message in a reply
2009-11-02, 10:13 AM
Post: #2
Re:Background Shell Script Problem
There was a change in the security model at Windows 6.0.
It changes the behavior of processes running in the background when the user logs off of the glass.
But you description sounds different because it sounds like your still logged on at the desktop/glass.
Or are you connecting with telnet/ssh and then logging out?
Let me know so I can try and replicate it the same way.

One workaround we suggested was to submit the script as a cron job.

Find all posts by this user
Quote this message in a reply
2009-11-02, 11:26 AM
Post: #3
Re:Background Shell Script Problem
I was doing it from the desktop, but our QA program logs in via telnet, either way they were both failing when that terminal exists. I will see if they can try it via the 'at' command since it is not something that is recurring, but something that only needs to be kicked off when our QA tool is testing on that platform.
Find all posts by this user
Quote this message in a reply
2009-11-17, 12:34 PM
Post: #4
Re:Background Shell Script Problem
We have had no luck getting 'at' to work at all. It creates the entry in the queue but it never executes. Is there something special that needs to be done to get 'at' to work properly?
Find all posts by this user
Quote this message in a reply
2009-11-17, 10:08 PM
Post: #5
Re:Background Shell Script Problem
When you installed did you activate "SetUid"?
For the user the 'at' will run as, did you register the user's password with the "regpwd command?

Find all posts by this user
Quote this message in a reply
2009-11-23, 10:23 AM
Post: #6
Re:Background Shell Script Problem
Yes, I enabled "SetUID" when I installed SUA tools and I registered a password with "regpwd", it wouldn't let me continue without it.
Find all posts by this user
Quote this message in a reply
2009-11-23, 12:35 PM
Post: #7
Re:Background Shell Script Problem
For the script being run by at what does it look like?
Did the user get any local email about the script getting an error? (local==on that machine)

Find all posts by this user
Quote this message in a reply
2010-05-06, 10:37 AM
Post: #8
Re:Background Shell Script Problem
I have the same problem.

Sometime, the "at" command do the job, sometime not. The entry are in the queue.

No message at all. No log, no mail, nothing.
Find all posts by this user
Quote this message in a reply
2010-05-06, 01:31 PM
Post: #9
Re:Background Shell Script Problem
What do you have the job doing?

Find all posts by this user
Quote this message in a reply
2010-05-07, 09:45 AM
Post: #10
Re:Background Shell Script Problem
Simply fire script "at" X time. Nothing realy complicated.

But I have to mention that crontab refresh every 5 minutes. We schedule new job in "cron" file and we schedule a job to refresh the crontab.

Maybe it interfere with the "at" command cause the cron daemon fire the job in crontab AND the "at" scheduled.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)