crontab

I want to run a perl script twice a day at 11:55 am and 11:55 pm. My system administrator does not have crontab installed or does not want to take the time to learn how to use it. I have my own domain and I have a cgi bin. How can I get this script to run automatically twice a day?
timshankAsked:
Who is Participating?
 
ahoffmannCommented:
while (1) { system("you script"); sleep 43200; }

start at 11:55

(not very nice, but simulates a cron;)
0
 
b2piCommented:
Change providers! :)
0
 
timshankAuthor Commented:
I'm not sure what to do with that information you just gave me, could you elaborate for me a bit please? I can configure a perl script w/ some work, but I am just learning the language
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ahoffmannCommented:
Write the first line of my first comment in a script (replacing "your script" with the appropriate path to the script you want to run twice a day), then start this script at 11:55.
That's all. It simulates the cron mechanism.
0
 
timshankAuthor Commented:
I put the following script in my directory that contains the perl script

#!/usr/bin/perl

while (1) { system("/home/www/myurl/scripts/accesswatch/accesswatch.pl"); sleep 300; }

and named it cron.cgi. I used the 300 to test if it would access it every 5 minuites

when I ran cron.cgi it ran the perl script but hasn't ran it since, what did I do wrong?

0
 
ozoCommented:
Is it still running?
0
 
timshankAuthor Commented:
how can I tell? is there a command I type in telnet to see if it is still running?
0
 
ahoffmannCommented:
ps -ef   or   ps aux
0
 
timshankAuthor Commented:
Here is the message I get when I type in either command. I did discover that the script will run as long as I have a telnet session open, but as soon as I lose my telnet link it won't update the script anymore.

heras:/www/myurl/scripts/accesswatch$ ps -ef
warning: `-' deprecated; use `ps ef', not `ps -ef'
Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      /proc   /proc   proc    defaults
  In the meantime, mount /proc /proc -t proc
Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      /proc   /proc   proc    defaults
  In the meantime, mount /proc /proc -t proc
heras:/www/myurl/scripts/accesswatch$ /proc -t proc
bash: /proc: is a directory
heras:/www/myurl/scripts/accesswatch$ ps ef
Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      /proc   /proc   proc    defaults
  In the meantime, mount /proc /proc -t proc
Error: /proc must be mounted
  To mount /proc at boot you need an /etc/fstab line like:
      /proc   /proc   proc    defaults
  In the meantime, mount /proc /proc -t proc
heras:/www/myurl/scripts/accesswatch$      
0
 
ahoffmannCommented:
Uups, you've a somehow limited telnet access :(

try following:

heras:$ cron.cgi&
heras:$ jobs

`jobs' should report something like

[1]  + Running     cron.cgi
0
 
timshankAuthor Commented:
It seems to be running. I didn't restart it when I initiated the new telnet session. Thanks for your help by the way, I love learning new stuff.

heras:/www/myurl/scripts/accesswatch$ cron.cgi&
[1] 19537
heras:/www/myurl/scripts/accesswatch$ jobs
[1]+  Running                 cron.cgi &
heras:/www/myurl/scripts/accesswatch$    
0
 
timshankAuthor Commented:
The script is running but it still is not running my perl script, why would that be?
0
 
ahoffmannCommented:
Sounds that you have a problem in your perl script.
Did you give a full path at perl's system() call?
You also may try following:

while (1) { system("/full/path/you_script >/tmp/log 2>&1"); sleep 43200; }
0
 
b2piCommented:
Hmmmph. Logging's a very good idea, verifying that all is running is a good idea, but....

You've got a provider that won't let you do a cron job, because "My system administrator does not have crontab installed or does not want to take the time to learn how to use it."
[Ob Side note: Anyone who doesn't _know_ how crontab works _isn't_ an SA, and anyone who doesn't want to take the time to learn isn't _worthy_ of being an SA.] Furthermore, if there's no cron on your system, maintenance is either not being done, or is being half-done by hand.

:) I want the points for "Change Providers".  If you increase the points, I'll take them for "Fire the System Administrator, and hire a high school kid" :)

([ozo and ahoffman]) No disrespect to your valiant efforts intended....Honestly, though, it's abominable that a user should have to put up with this kind of .... sewage!

Cheers
0
 
adrianwardCommented:
A thought: Wont the script get killed as soon as the user logs off?

My knowledge in this area is weak and I dont have my documentation with me, but could you use nohup?

ie, when you come to run your cron-script, do it as
heras:/www/myurl/scripts/accesswatch$ nohup cron.cgi &

which will prevent it from receiving quit signals (sent by your shell when you log out)
0
 
timshankAuthor Commented:
the nohup worked, but unfortunatly I had it set to run every 5 minuites because I was testing it. Now the file keeps running every 5 minuites instead of every 12 hours. I even deleted the cron.cgi off of my site and it still keeps running, how can I stop it so I can restart it to run every 12 hours? Thanks
0
 
ahoffmannCommented:
> how can I stop it

   ps ax
or
   ps -ef
(depends on the OS) will give you the PID, the do a
   kill -TERM <PID>

If you hav no shell access to the system, you also may do it via perl.
0
 
timshankAuthor Commented:
It wont give me the pid, it keeps telling me that proc needs to be mounted. what are my other options?

(I'm about ready to take b2pi's advice on this one)
0
 
ozoCommented:
How about renaming your
/home/www/myurl/scripts/accesswatch/accesswatch.pl
:-)
0
 
ozoCommented:
Or how about replacing it with a program that looks at its ppid and kills it?
0
 
b2piCommented:
It looks to me like he's on a proc FS system, and doesn't have read access to /proc.  Be willing to bet this is Linux, and you don't have an SA.

If that's the case, I think that any method you would use to get a pid or ppid would fail for the same reason.... Hmmm, except maybe ozo's last one.  That could work.

Honestly, I first proposed it as a joke.  You've been playing about with trivia for a month now.  People like this don't deserve to stay in business.
0
 
ozoCommented:
unfortunately, if you used
 system("/full/path/you_script >/tmp/log 2>&1")
then getppid would be the pid of the shell doing the redirection, instead of the program doing the system call...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.