Solved

How to Run cronjob in Linux

Posted on 2000-03-28
2
391 Views
Last Modified: 2010-04-20
Hi Linux Expert,
I'm Linux Novice. If I want to run cron job in my Linux server to periodically(at 8am, 12noon and 5pm every day except Sunday) copy some files from one Linus server to another backup Linux server, what need to be set up on the server that will run the cron job?
Pls describe how to check and set up the required deamon to run.
And give a sample of the cronjob entry format too.
TQ,
Jiayi
0
Comment
Question by:jiayiloo
2 Comments
 
LVL 1

Accepted Solution

by:
bcoleman earned 50 total points
Comment Utility
Run 'crontab -e' as root to edit the file you set up for cron jobs.

Format of crontab file:
M H D M W N

M - Minute
H - Hour
D - Day of Month
M - Month
W - Day of Week ( 0 or 7 = Sunday )
N - Path of file to run

A field may be an asterisk(*), which always stands for "first-last"

Your file:
0  8 * * 1-6 /usr/bin/yourscript
0 12 * * 1-6 /usr/bin/yourscript
0 17 * * 1-6 /usr/bin/yourscript


/usr/bin/yourscript can be a script you write to copy the files necessary or a program you write.

To check is cron is running.
1. One way is to do a 'ps ax', and see if cron or crond is running.
2. If running RedHat run linuxconf go into Control-><Control Panel>->Control Service activity and see if cron is running that way.  If not you can setup cron to start every boot up, and you can start it manually then to.

Hope this helps!!!
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
You can also run "crontab -e" as a user and the system will create a crontab for that user. It's not required that all cron jobs be run from root's crontab.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now