Solved

Timers

Posted on 1999-01-18
7
194 Views
Last Modified: 2010-03-05
I use Unix

Is there a command in perl where you can say something like:

In 30 min execute {
(stuff to execute)
}

And that it would do it, even if the user's browser is no longer open?  Thanks
0
Comment
Question by:jknickelbein
7 Comments
 
LVL 4

Expert Comment

by:martinag
ID: 1210195
Check
  man at
and
  perldoc -f localtime

I've got to go now, but I'll post some code tomorrow (or someone else will do it before...).

Martin
0
 
LVL 1

Expert Comment

by:ptruman
ID: 1210196
Unless you had Perl spawn another process at runtime,
the only way you'd get it going is to system an "at" command.
A keepalive connection would (in theory) work but it's doubtful
they're going to keep a page open for 30 mins...

0
 

Author Comment

by:jknickelbein
ID: 1210197
Using the at command is kinda what martinag already said.... if you can explain how to use it, I'll award to him the points.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:jknickelbein
ID: 1210198
Really, all I need done, is that 30 minutes after my user logs into my script, I want to delete a certain file, thus expiring the session.
0
 
LVL 4

Expert Comment

by:martinag
ID: 1210199
# Random file name
$file = "exec" . time . "pid$$.ex"; # millisecs since 1970 and pid should be enough random

# Write file that should be "executed"
open (FILE, ">$file") or die "can't open $file for output: $!";
print FILE "rm ..."; # The command
close FILE;

# Calculate time
@time = localtime;
$h = $time[2];
$m = $time[1] + 30;
if ($m > 59) {
  $h = 0 if $h++ == 24;
  $m -= 60;
}

# Set timer
system("at -f $file " . sprintf("%2d:%2d", $h, $m));

Martin
0
 
LVL 1

Accepted Solution

by:
Cov earned 20 total points
ID: 1210200
Hey...

Another approach you could use would be to simply keep a process excecuting on the server which makes sure everything is cleared out if it is 30 minutes old... just clearing the directory every 30 minutes would work, but then some people would have shorter "login" times than others.

Try something like this:
Build a perl script which will check the directory every minute for aged files and delete them.  When it launched, have the script record its PID (process id) to a file.

No, have your other perl scripts which users interact with have a function that just occasionally checks that data file for the pid and checks to see if it is still alive.  If it isnt, have it reexecute ... that is your safe guard...

And voila:)  Every thing will run fine...
i still think it would be simpler just to have you login script clear out old entries... it would not take much process time...
Cov
0
 

Author Comment

by:jknickelbein
ID: 1210201
Ok... thanks guys!

Cov - as long as it should take to long (process time) to clear out all over 30min. entries, that's probably what I'll do.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now