Solved

How to Run cronjob in Linux

Posted on 2000-03-28
2
393 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
ID: 2664174
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
ID: 2664237
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

830 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