Jump to content

Cron not working


Recommended Posts

I've been trying to learn a few new things with linux lately, one of them being how to run scheduled tasks with cron, but I must be doing something wrong because it doesn't appear to be working. Basically, what I'm trying to do is get my antivirus (f-prot) to run at a certain time every night. This is what the /etc/crontab reads:

 

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/f-prot

MAILTO=root

HOME=/

 

# run-parts

01 * * * * root nice -n 19 run-parts /etc/cron.hourly

02 4 * * * root nice -n 19 run-parts /etc/cron.daily

22 4 * * 0 root nice -n 19 run-parts /etc/cron.weekly

42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly

 

I used vim (which I'm also recently learning to use!) to edit a root crontab, and this is what I used:

 

# DO NOT EDIT THIS FILE - edit the master and reinstall.

# (/tmp/crontab.16368 installed on Sun Sep 10 12:22:27 2006)

# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)

* 2 * * * root ./f-prot / -silent -report=/home/****/virusscan

 

I set f-prot to run silent and print out a report in my home folder, but it doesn't seem to do anything, I've checked the root mail folder and it isn't printing anything in there either. Any ideas what I'm doing wrong?

 

Also, I downloaded a gzipped tarball, tarred it into my home directory, ran the config script, and it told me to run jam to build the program. I had never heard of jam, it wasn't built into mandrake, so I downloaded an rpm, got it installed and working, that's a cool command, anyone else ever heard of it? If so, how else could it be used? Thanks for any help!

 

 

[moved from Software by spinynorman]

Link to comment
Share on other sites

Those are the exact steps I took, as root I typed into a console "crontab -e", after vim opened, I typed in what I wanted to run, then hit the esc key to get back to normal mode, typed ":wq", then typed "crontab -l" to check that all was correct, and it still won't do anything. I've checked in /var/spool/mail/root for any output, nothing is showing up. I'm sure the crond is running, and I'm sure my mail program is installed and working properly. Just to make exactly sure, the order in which the times are entered are minute, hour, day of month, month, and day of week, correct? That's the only thing I'm not 100% sure about, and the only thing I can see that is causing it not to run when it's supposed to. Thanks.

Link to comment
Share on other sites

I'm currently using Vixie cron v3.0.1, not real sure if it supports the user column, after grepping /var/log/messages it seems as if it was trying to run root as part of the command- CMD (root echo "why isn't this thing working?"). I took the user column out, ran it again, it still isn't producing any output anywhere, it's entirely possible it is working, just sending the output somewhere other than /var/spool/mail. Any ideas?

Link to comment
Share on other sites

./f-prot / -silent -report=/home/****/virusscan

 

The "./" in front of f-prot indicates to me that f-prot is not in PATH. To run that command you would have to cd to the directory where f-prot resides and then run that command, i.e.:

 

cd <full path to f-prot directory> && ./f-prot / -silent -report=/home/****/virusscan

Link to comment
Share on other sites

Ok, it worked doing it that way, but the confusing thing is I'd put the path to the f-prot executable in the /etc/crontab file, shouldn't it have looked there and executed the program anyways? Another unexpected result was that when the daemon started, it spawned about half a million processes, and kept spawning them, never completing the first process, eventually locking my pc up. Guess I'll have to work with it, see what I did wrong and fix that. Thanks for all the help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...