Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to schedule a periodic task on RedHat Linux server?

Status
Not open for further replies.

manirana007

Programmer
Jul 11, 2006
17
GB
Hello,

I want to schedule a restart of Linux machine every day at night (1pm). And then have it start Weblogic server. I found that cron is a linux schedular, if so, how to schedule using it. Any ideas would be helpful. Thanks.
 
Use a text editor to edit /etc/crontab . There should be some entries there already, and the columns will probably have explanatory headings.
 
If you can't figure out what's going on from your existing crontab file or if you want more details, you might try:

[tt]man 5 crontab[/tt]

at a command line.



Want the best answers? Ask the best questions! TANSTAAFL!
 
My preference is to leave /etc/crontab alone. The default crontab on RHEL has this:
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

So, any executables in these directories are run at the appointed time. For more control, create a crontab-style file in /etc/cron.d for the tasks.

Finally, as an ordinary user you can create your personal crontab via "crontab -e".
 
Before we get into scheduling, <rant>why on God's green earth do you need to reboot every night?</rant>

Now with that out of the way, just create a file with any name with this one line in it:

Code:
0 1 * * * /sbin/shutdown now -r

Then load it as root:

Code:
crontab -u root [i][filename][/i]

You will however need to make sure that your boot loader has a default time-out and points to the right kernel.

As for your weblogic, does it have it's own init script? I can't say how you can start the service as different distro's have different ways of configuring services and you didn't specify yours. RedHat/Fedora and their derivatives use chkconfig.


--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top