Cron process only during a particular login ?

Cron process only during a particular login ?

Post by Thierry G. Thelli » Fri, 13 May 1994 05:12:22



Is it possible to execute a process (let say every hours)
when a particular user is logged in ?

I mean:
   The process should start when the user logs in.
   The process should be executed every hours.
   The process should be no longer called when the user logs off.

Thank you
Thierry

 
 
 

Cron process only during a particular login ?

Post by Lar Hanl » Fri, 13 May 1994 08:47:15



: Is it possible to execute a process (let say every hours)
: when a particular user is logged in ?

: I mean:
:    The process should start when the user logs in.
:    The process should be executed every hours.
:    The process should be no longer called when the user logs off.

: Thank you
: Thierry

--
Mr.T.,

assuming you have already looked at the man page for cron, you're probably
interested in the contents of a cron command to do the above.  this command
can be accomplished with an if statement.  for example, in a single line:

if ps -ularh | egrep "[-]ksh" 1>/dev/null 2>&1; then echo "im here";
  else echo "im not here"; fi

the command is broken in two to accomodate my news viewer, but must be in one
line for cron.  the echo commands could be replaced with anything you like.
beware that mischief could be accomplished the same way, so systems people
like to restrict cron capability.  the 'larh' above is my userid and '-ksh' is
a line that appears in my set of processes whether logged on in windows or
without windows.  hope this helps.

------------------------------------------------------------------------------

Colorado Springs Tech Center | construed as anything but my humble opinion.
Hewlett Packard Company      | HP is under no obligation to support it.
------------------------------------------------------------------------------

 
 
 

Cron process only during a particular login ?

Post by Brian Lawl » Sun, 15 May 1994 02:18:14



: Is it possible to execute a process (let say every hours)
: when a particular user is logged in ?

: I mean:
:    The process should start when the user logs in.
:    The process should be executed every hours.
:    The process should be no longer called when the user logs off.

We have the same need.  Or solution so far is to have a program run
by the root cron.  That program checks to see if the user is logged in
(actually, we are checking to see they are logged in and running a
particular program so we use ps) using who and, if they are, runs a
script.  Hack city but it works.
Can it be done better?  Please let me know too.