Cron and File Manipulation

Eric Anderson anderson at centtech.com
Fri Apr 1 12:01:03 PST 2005


Kris McElroy wrote:
> First of all I am a newbie to FreeBSD and if I need to be pointed somewhere
> else let me know.
> 
> I have 2 questions
> 
> I have a .sh script that I want to run every 25 minutes everyday
>   So would I do the following:
> 	25    *       *       *       *       root    /usr/local/bin/MY.sh >
> /dev/null 2>&1
> 
> 
> Also in the above script I want to add a line in my log file 
> 
> Echo >> MY SH Completed
> 
> The thing is I would like to date and timestamp it, how could I do that?

Hey Kris!  Welcome to FreeBSD..  These are pretty basic Unix essentials, and you might like reading through parts of the FreeBSD handbook (available on the freebsd.org website).  

On your crontab, you've actually got it set to run at 25minutes after the hour, every hour, not every 25 minutes.  You can have it run every 20 minutes for example, by doing this:

*/20    *       *       *       *       root    /usr/local/bin/MY.sh > /dev/null 2>&1

That would run on any minute divisible by 20.

For date/timestamping, a simple way could be:

echo -n `date` >> logfile
echo ": normal log text" >> logfile


Eric


-- 
------------------------------------------------------------------------
Eric Anderson        Sr. Systems Administrator        Centaur Technology
A lost ounce of gold may be found, a lost moment of time never.
------------------------------------------------------------------------


More information about the freebsd-isp mailing list