Tuesday, October 1, 2013

How to Apply Crontab

www.unixbabuforum.inI would like to empty the cache automatically daily , I creat one crontab but is not applying 

How I can apply the daily Crontab ? 
www.unixbabuforum.inread the manual for yourself, but see this: 

?The time and date fields are:

field??? ???? allowed values
-----??? ???? --------------
minute??? ???? 0-59
hour??? ???? 0-23
day of month?? 1-31
month??? ???? 1-12 (or names, see below)
day of week??? 0-7 (0 or 7 is Sun, or use names)

And you are posting this: 

21 12 * * * * /etc/webmin/cron/tempdelete.pl 

You are giving SIX time fields, and the manual has FIVE. Please remove one of the * items. 

It will then run your script as named, at 12:21 every lunchtime, which is probably not the best time to rip squid down. Maybe you intended 21 0 * * * ... to mean 00:21 early in the morning.www.unixbabuforum.inYou should try to find your cron logs. These might show you the issue. I can't tell you where these are because every system is different. Some use the syslog command, others are in /var/logs or somewhere like that. You will need to google for your specific OS to find them. 

As a test, try setting up the dumbest test you can. Like a crontab entry of: 

* * * * * touch UniqueCronTouch.txt 

and maybe 

* * * * * date >> UniqueCronTouch.txt 

Then search for that filename, and make sure its datestamp gets changed every minute. At least that proves you have cron privileges. It avoids issues with paths etc because it is a system command, and also issues with script permissions. 

Some other things that can be wrong: 

your cron file must have permissions only for root and you. (This stops people planting jobs there that will be executed with your permissions and without your knowledge). 

There may be files around with names like cron.allow and cron.deny that prohibit specific users. 

There are other files with names like queuedjobs that control how many jobs you can start in background at once. These can have the number of jobs set to 0 so you can't run any. 

As you have not published your system or OS details, we cannot give exact names. Cron is fairly variable. Even if you do tell us, I would have to just google because I will not have the same OS as you. So best if you learn how to look up information yourself - you are goin to be doing it for a long while. 

When you run up against a problem like this, you have to think what you can try that shows where the problem is. Start with the simplest possible test that might give a result, never assume anything you have not proved, and build towards you eventual design gradually

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM