PDA

View Full Version : Do these crons look correct?



JerryS
04-16-2009, 07:27 PM
Can someone let me know if these look OK?

059 * * * * /var/www/cgi-bin/arp3-auto.pl
45 23 * * * /var/www/cgi-bin/arp3-report.pl
*/5 * * * * /var/www/cgi-bin/arp3/arp3-popreader.pl


Thanks in advance

Jerry

wildjokerdesign
04-17-2009, 07:13 AM
They don't look quite right. :)

Here is a resource to read: http://en.wikipedia.org/wiki/Cron_job

The first one with 059 does not follow correct format. Should be 59.

You need to supply the path to perl in them.

Here is what I think they need to be:

59 * * * * /usr/bin/perl /var/www/cgi-bin/arp3-auto.pl
45 23 * * * /usr/bin/perl /var/www/cgi-bin/arp3-report.pl
*/5 * * * * /usr/bin/perl /var/www/cgi-bin/arp3/arp3-popreader.pl

I am not 100% sure if the */5 works on a WestHost account. I know it is not a default of cron.

JerryS
04-17-2009, 08:24 AM
Thanks for the set of eyes.

Eliminated the 0. Don't know what was going on there.

Oddly enough the installed program ARP is reporting crons are running without the preceeding /usr/bin/perl

Leave it or add it? I guess it wouldn't hurt to edit with new info.

I did read somewhere here that */ may not work. Not a real difinative answer one way or another from what I recall.

wildjokerdesign
04-17-2009, 08:45 AM
Jerry,

I think you need the path to perl. Cron jobs are just like running an SSH command. Without the perl it would not "know" what to do. It could be that your ARP program is simply saying that you have activated the cron jobs. The true test is to see if what is supposed to happen when those files are run happens is happening. Wow that was one messed up sentence. :)

JerryS
04-17-2009, 08:49 AM
I must be one messed up individual. I understood that sentence perfectly :) I Just finished editing crontab to include the path to perl.

Thanks for your help.

kgriffiths
04-18-2009, 12:19 AM
Dear JerryS and Wildjokerdesign,

Yes the */5 * * * * command does work inside the WestHost system. It means that it is going to run every 5 minutes.

If there is a problem with the cron job you set up from SSH, it will tell you that it cannot run the crontab due to errors in the cron job syntax.

Here is a great resource for the current WestHost crontab syntax and usage:

http://helpdocs.westserver.net/v3/sitemanager/Using_Cron.htm

JerryS
04-18-2009, 08:34 AM
Kevin,

While the resource referenced does detail using syntax it offers very few examples of commands. It would be a useful reference for an experienced user that understands how commands are written, but then someone with those qualifications probably doesn't need a resource.

An example or two sure would help. One must see is a typical cron that runs every 24 hours and executes a popular command.

Using the referenced resource for my question of this example:
*/5 * * * * /usr/bin/perl /var/www/cgi-bin/arp3/arp3-popreader.pl

or as originally questioned:
*/5 * * * * /var/www/cgi-bin/arp3/arp3-popreader.pl

tells me it should look more like:
*/5 * * * * /home/accountname/cgi-bin/arp3/arp3-popreader.pl

Is my understanding correct? Account name is without .com, correct?

Thanks,

--Jerry

bruce.binder
04-18-2009, 11:12 AM
Jerry:

The /home/accountname part is just an example. You should use the full path of the script you wish to run.

If the installed program ARP is reporting crons are running, then it sounds like you are in business.

You might not need the path to perl if the first line of the script has it. Typically, this would look like "#!/usr/bin/perl". This is sometimes called the "hashbang" or "shebang".

http://en.wikipedia.org/wiki/Shebang_(Unix)

--
Bruce

JerryS
04-18-2009, 11:53 AM
Bruce,

This is what baffles me... well a lot of things do but I'll stick to the present conversation.

ARP's administration page reports the last cron event. Since adding /usr/bin/perl no cron events since yesterday at 07:59 am are reported. I don't know if that change had an effect or is relevant but sure is coincidental.

Jerry

bruce.binder
04-18-2009, 06:37 PM
Jerry:

If ARP thinks they are not running then I think they are not running.

My suggestion is to find the exact path to where the scripts are installed. Then run them from the command line, with and without the preceding /usr/bin/perl. Whichever way works (you can check the ARP administration page) use that exact command in your crontab file.

P.S. You might not have a /home/accountname/cgi-bin directory. On one of my accounts, it's in /home/accountname/www/cgi-bin.

--
Bruce

wildjokerdesign
04-19-2009, 06:18 AM
/var/www/cgi-bin is the direct path to the default cgi-bin. Others are just symbolic links.

JerryS
04-19-2009, 09:47 AM
I am beginning to empathize with westhost's refusal to provide support with cron issues. Way too many variables.

Setting up a cron job is likely different (although I'm unsure) between the account types available; shared, dedicated, VPS, etc.

I do recall using the path /home/accountname/www/public_html/cron job in the past (the public_html part may be incorrect) in a shared environment using cpanel on another host.

Or is /home/ another way of reaching /var/www/ ?

Or is /var/www/ unique to my plan?

I arrived here after doing a search for hosts which allowed user configuration. I needed a few additional scripts installed and my previous host said no, so I said goodbye. Moving here has allowed me to be in control, to an extent, and I am very appreciative. Although there is a lot to learn to be in control it is my hope this aspect does not change once a migration to cpanel is made.

I edited crontab and removed /usr/bin/perl and the scripts are running again. I do not know the command for running a cron in shell and so editing and waiting is the approach I knew and used. I'm sure the instructions for executing a commandit is somewhere between the lines in all the pages read in the last several days and I didn't recognize it when I saw it.

All over the map with thoughts and questions here but you know what they say; a little information is a dangerous thing.

--Jerry

JerryS
04-19-2009, 02:09 PM
And how about this cron for Drupal:

0 * * * * /usr/bin/wget -0 - -q -t 1 http://mydomain.com/cron.php

Sure looks OK to me.


--Jerry

wildjokerdesign
04-20-2009, 10:22 AM
Your Drupal cron should work fine.

BTW: You might want to edit your post above so the URL is not turned into a hyper link. In fact you might want to replace your domain with an example.com. Do you really want folks running your Drupal cron file. ;)

JerryS
04-20-2009, 10:37 AM
Edited.
Thanks for pointing that out.
I am receiving an enormous amount of questionable log entries at my site. Could having that cron job code here be causing a problem?

wildjokerdesign
04-20-2009, 11:08 AM
The URL is being turned into a hyper link by the Forum software, search engines and people follow links. ;) It could be causing some entries in your logs. Now that you have changed it, it should be ok. You can always use the BBcode to place code inside of "code" tags. That keeps your URLS from hyper linking, although I always still replace personal info with generics.