cron tab newbie

cron tab newbie

Posted by: thedragonmaster
Posted on: 2008-08-31 01:10:00

hello folks. ive read the dreamhost wiki on crontab and man am i lost! ive never used it before tho i have used the shell using putty. id like to learn the basics at best but right now all i want to do is what i tholt would be a simple file move copy for a few files replacing another.

example lets say i have a file called footer.html and i want it to change on a certain day of the week for a special ocasion or such. so how would i go about doing say..

monday footer.html.monday > footer.html
tuesday footer.html.tuesday > footer.html

etc.

and is there a crontap for dummies tutorial online some where?

Re: cron tab newbie

Posted by: patricktan
Posted on: 2008-08-31 02:44:00

crontab itself goes according to minutes, hours, days, months, and years. It does not know monday or tuesday.

To achieve your goal, you may want to try to write a PHP or Perl script to update the files according to monday or tuesday. And crontab job will run the script everyday.

Re: cron tab newbie

Posted by: thedragonmaster
Posted on: 2008-08-31 04:07:00

way over my head.. ok so lets say i just want to change it for a holiday?

Re: cron tab newbie

Posted by: sdayman
Posted on: 2008-08-31 06:46:00

If you want to start using Cron, then you'll have to know some shell scripting:
http://wiki.dreamhost.com/Shell_Commands

But your crontab file should look something like:
1 0 * * 0 /bin/cp -f ~/footers/sunday.html ~/mysite.com/footer.html
1 0 * * 1 /bin/cp -f ~/footers/monday.html ~/mysite.com/footer.html
1 0 * * 2 /bin/cp -f ~/footers/tuesday.html ~/mysite.com/footer.html
(at 1 after Midnight, on Sundays/Mondays/Tuesdays regardless of day of month and month, force copy the sunday/monday/tuesday footer)

2 0 25 12 * /bin/cp -f ~/footers/christmas.html ~/mysite.com/footer.html
(at 2 after midnight on Day 25, Month 12, regardless of day of week, force copy the Christmas footer)

-Scott

Re: cron tab newbie

Posted by: thedragonmaster
Posted on: 2008-08-31 06:56:00

ah! thank you, now i can start to learn with cron. quick question however, if i "mess up" in cron will it cause issues for others on the server or on my own account? i dont want to do anything that would adversely affect other users.

Re: cron tab newbie

Posted by: sdayman
Posted on: 2008-08-31 08:00:00

It will only cause issues if the command you're using overloads the server, which is unlikely. You're just using basic UNIX commands which will run very briefly. Should it run for some extended period of time, an automated bot will kill it.

-Scott

Re: cron tab newbie

Posted by: sXi
Posted on: 2008-08-31 08:06:00

http://wiki.dreamhost.com/Crontab#Basics

Just be careful not to have your jobs (inadvertently) performing intensive operations too often.

Don't have it backing up a 200MB database every 7 seconds instead of every 7 days, etc.



Tags: crontabfooterthowikishell