Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How to use Cron?

Quote Reply
How to use Cron?
Hi,

I'm using/testing the Links 2.0. I'm new when it comes to Unix/Linux servers, and have a few questions regarding Cron.

Can anyone give me, or point me to a site where i can learn how to setup Cron scripts? I checked with my ISP, and they suported this function, but did not have any ideas for "How To" guides.

It would be of great help if anyone could help me out with this.

Best Regards,
Terje Dahl - spear@online.no
Quote Reply
Re: How to use Cron? In reply to
You're going to need a shell account (telnet) to be able to set up a chron job unless you just need to e-mail support at your provider. I could go into detail of how to set up a chron job on Solaris, but I don't know if the process is completely the same on the variant of Unix/Linux that you're using. If you know which which Operating System your server is running, there is generally a FAQ that will have that type of information available. All of the Linux distributions have pretty good FAQ's and should be able to help you.
Quote Reply
Re: How to use Cron? In reply to
 
1- for editing your own user cron file
unix> crontab -e
you entering in a text editor

2- configure your cron command
# 1 minute (0-59),
# 2 hour (0-23),
# 3 day of the month (1-31),
# 4 month of the year (1-12),
# 5 day of the week (0-6 with 0=Sunday).
# full path to your script or command
#1 2 3 4 5 6
10 23 * * * /home/user/cron/script/links.sh
# this line excute on each day at 23:10 #links.sh script.

if you want more information
you can use man command under your unix system

Cheer
Martial
Quote Reply
Re: How to use Cron? In reply to
An easier way of doing it is to setup the event you want to use in a text file (offline) and upload it via ftp as an ASCII file, calling it something like mycron.txt.

Then, login to the shell account via telnet and, at the command line, type the command:

Quote:
crontab mycron.txt

That will load the event containined in mycron.txt into the cron table. You can view the table using the command:

Quote:
crontab -l

For details on setting up the cron event, use the following command at the shell prompt:

Quote:
man crontab

I hope this helps.
Quote Reply
Re: How to use Cron? In reply to
My ISP also did not have any information, when I wanted to setup a cronjob. He recommended me to look in to an UNIX book. Their service is pretty good and we can not expect them to help on all the technical details, I guess. Take a look at this document.

http://www.infoboard.com/...ase/98-9-9-12649.htm

Create a text file called "cronjob" or whatever, in the manner explained by martial above and upload it to your root directory by FTP.

Then login by telnet and input command at the prompt ex:

yourserver:~$crontab cronjob

This will upload your file to crontab.

Go back at the prompt and say crontab -l to see if it uploaded the file. Now you should see the contents of your text file. To findout all the commands type crontab and it will list all the commands (varies by system).

You are all set. The job will be executed according your time interval.


[This message has been edited by socrates (edited April 08, 1999).]
Quote Reply
Re: How to use Cron? In reply to
I am having a problem with the cron job I set up for LINKS (running on a UNIX server...I know it may be confusing with my posts in these forums since I am running these scripts on different web servers and operating platforms). I tried to add a line in the .sh file that would delete all detailed pages before re-building them. (I am also having a problem with being able to delete the files in the detailed directory.)

Anyway, here is the error message I receive in the build_links.log file:

Generating detailed view pages . . .
Content-type: text/html

<PRE>

CGI ERROR
==========================================
Error Message : Unable to build detail page: /mnt/web/guide/anthrotech/resources/links/detailed/1.shtml. Reason: Permission denied
Script Location : /mnt/web/guide/anthrotech/cgibin/wwwvl/admin/nph-build.cgi
Perl Version : 5.00404

Form Variables
-------------------------------------------

Environment Variables
-------------------------------------------
HOME : /mnt/web/guide/anthrotech
LOGNAME : anthrotech
PATH : /usr/bin:/bin
SHELL : /bin/sh
USER : anthrotech

</PRE>

Anyone know how I can correct this?

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: How to use Cron? In reply to
Bobsie,

Thanks. I did get it to work. I deleted all the files and directories, which was time consuming. I tried installing the delete all mod (offered by LLINKS), but I got error messages. So, I manually deleted the files and directories.

You are right...It is a lot faster to build via Telnet. The only problem I now have is running Cron multiple times during the day. I set up the cron file as you instructed in the FAQ section of the Resource Center, but my cron job only seems to run at 1:00 a.m., even though I set-up the mycron.txt file to 1:00 a.m., 6:00 a.m., 1:00 p.m., and 10:00 p.m.
(i.e., 1,6,13,20).

Oh well...I think that my ISP has restrictions on how many times cron can be run.

Never mind...I have to use the crontab editor (crontab -e) to make the changes. Making changes in the mycron.txt file doesn't make a difference.

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited July 04, 1999).]
Quote Reply
Re: How to use Cron? In reply to
Eliot,

The detailed directory needs to be world writable in order for the script to build the pages. If Links creates the directory itself (instead of you creating it from the shell), it should do it with the correct permissions. However, the cron event may not be able to delete the files since they will be owned by the script (user nobody). If you chmod the directory to 777, both the script and the cron event can manipulate the files but then, so can anyone else, via the web, as well.

The best way to do this is to modify the script to delete the files before doing a rebuild. See the sub build_update_ratings in nph-build.cgi for an example on how to read in a directory and delete all the files in it.

I hope this helps.



[This message has been edited by Bobsie (edited July 04, 1999).]
Quote Reply
Re: How to use Cron? In reply to
Can more than 1 cron routine be placed in the same .sh file?

Also can more than 1 event be loaded in to crontab through the same file ie: mycron.txt ?


------------------
Joker
Concepts 2000 Online
www.concepts2000.com
tech@concepts2000.com



[This message has been edited by Joker (edited August 27, 1999).]
Quote Reply
Re: How to use Cron? In reply to
Yes and Yes. A cron event is just an automated way for your system to perform commands. It does it just as if you typed the commands yourself. You can put any number of commands in mycron.txt and add it to your crontab. Each command done this way will require a separate setting as to when it is to run.

If you setup an event to run a .sh file and put the commands in the .sh file, then you only need one entry in the crontab to execute it. Each command in the .sh file will be processed in the sequence entered as soon as the previous command has completed.

I hope this helps.

[This message has been edited by Bobsie (edited August 29, 1999).]
Quote Reply
Re: How to use Cron? In reply to
How would be the cron code if I want to run the script every hour.... ?
thanks
Quote Reply
Re: How to use Cron? In reply to
Code:
0 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 * * * /path/to/build_links.sh

Change /path/to/ to the ABSOLUTE PATH where your build_links.sh is located.

BTW: As I mentioned previously in this Thread...your ISP may impost restrictions on the number of times you can execute individual crontab jobs...so be aware.

REALLY hope this helps.

Regards.

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: How to use Cron? In reply to
tmoretti,

I believe the hours are defined as 0-23 not 1-24. I'm not sure if this works, but you can also try to use * for the hour setting.

Cary
Quote Reply
Re: [socrates] How to use Cron? In reply to
What was the information at http://www.infoboard.com/infoboard/kbase/98-9-9-12649.htm
? I clicked through but it was forbidden, apparently no longer accessible....
--Sanguinarius
Your resident vampire ;P
http://www.sanguinarius.org/