LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 02-23-2011, 08:52 AM   #16
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,205

Rep: Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472

Quote:
Originally Posted by Reuti View Post
Annotations:

a) This will start the script for each login. Will the users login twice? Then you would have two or more instances for each user.

b) Will the scripts ever be stopped again? Especially with nohup they will survive the logout AFAIK.
Very true for point (A), although there could be some 'smarts' put into the script to check for a running instance, and not start a second time if so. Wouldn't be too hard to do.

But no, the nohup will just start a second 'shell' in the background. Once the user logs out, it'll also kill that shell too.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-23-2011, 09:13 AM   #17
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
The & at the end of the line will fork the process in the background, and will be killed by sighup when the terminal session is closed. By using nohup the signal will be ignored and the script surives.
 
Old 02-23-2011, 09:38 AM   #18
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,205

Rep: Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472
Quote:
Originally Posted by Reuti View Post
The & at the end of the line will fork the process in the background, and will be killed by sighup when the terminal session is closed. By using nohup the signal will be ignored and the script surives.
Ahh...I see where you're going.

I assumed the folks would be logging in via console/GUI, and once THAT closes, the session the user started will die. But for a terminal/ssh connection, you're exactly right. Good catch. In that case, OP, you can just omit the "nohup" from the front of the command.
 
Old 02-23-2011, 01:45 PM   #19
unassassinable
Member
 
Registered: Sep 2010
Posts: 46

Original Poster
Rep: Reputation: 7
Today is my day off, so I won't be able to test anything till tomorrow. But, for more info and clarification, the users all log into a GUI desktop environment. They open firefox, login to our CRM, and make calls all day. Then they go home. Most of the time they log out, sometimes they forget. So if I called the script from the /etc/profile like so:

Code:
nohup myscript.sh >/dev/null 2>&1&
when they log out, that should kill the process right? Only one person logs into any given computer. In other words, only bob logs into computer A, only sherry logs into computer B...
 
Old 02-23-2011, 02:21 PM   #20
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
Okay, then GNUbatch is no option. I thought that all log into one machine via ssh. Nevertheless, on my openSUSE 11.3 with KDE the nohup background process survives when I log out. In this case, I would just put it in ~/.kde4/Autostart to be started w/o nohup or & backgrounding.
 
2 members found this post helpful.
Old 02-23-2011, 03:48 PM   #21
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,205

Rep: Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472Reputation: 2472
Quote:
Originally Posted by Reuti View Post
Okay, then GNUbatch is no option. I thought that all log into one machine via ssh. Nevertheless, on my openSUSE 11.3 with KDE the nohup background process survives when I log out. In this case, I would just put it in ~/.kde4/Autostart to be started w/o nohup or & backgrounding.
+1

Have to agree with this, given this new info...and providing they use KDE. Although, Gnome has similar options to autostart a process.
 
1 members found this post helpful.
Old 02-24-2011, 03:39 PM   #22
unassassinable
Member
 
Registered: Sep 2010
Posts: 46

Original Poster
Rep: Reputation: 7
I removed calling the script from /etc/profile and moved the script from /usr/local/bin to my users ~/.kde4/Autostart, rebooted, logged in, downloaded a few test .gsm files, ran watch ls -l on my Download directory, and sure enough it runs every minute! Thanks for guiding me through this. It's cool to see what solutions people can come up with. Because we are using ldap, rather than local logons, I then created a script that will allow me to quickly copy the file to everyones (like several hundred users here!) /kde4/Autostart directories:

Code:
#!/bin/bash
UHOME="/home"
FILE="/home/rich.johnson/.kde4/Autostart/convertfromgsm"
USERSUSERS="$(ldapsmb -l -u | cut -d: -f1)"
for u in $USERSUSERS
do
   _dir="${UHOME}/${u}/.kde4/Autostart"
   if [ -d "$_dir" ]
   then
      cp "$FILE" "$_dir"
      chown $(id -un $u):users "$_dir/convertfromgsm"
   fi
done
Lastly, I copied the script the /etc/fstab/.kde4/Autstart directory as well, so that when I create new users in teh future they will have that file. I did have to create the .kde4 and the autostart folder in the skel dir.

Thanks again everyone, rep added.
 
  


Reply

Tags
crontab, opensuse112, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run linux script without having to be logged in matsko Linux - Software 5 04-05-2009 02:21 AM
who reports no user logged in /var/run/utmp when using kdm (Etch) forgox Debian 3 05-31-2006 04:21 AM
auto run bash script when logged in linuxmandrake Fedora 1 06-11-2005 08:22 PM
shell script to calculate the time a user is logged in racer_mec Linux - Newbie 2 02-08-2005 11:40 AM
mozilla works fine when logged in as a user but crashes when logged in as root jimi Linux - General 6 04-02-2003 08:34 PM


All times are GMT -5. The time now is 02:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration