Featured Products
Product Details
 
 
 
Customer Comments
800-672-4806 | 425-672-4806 | sales@ccscentral.com
User Guest (38.107.179.210)

Scheduling tasks on Linux

E-mail Print

Using Linux Cron

There are many tasks that are done periodically on a Linux system.  System cleanup, or monitoring, are common ones, as is backing up your system.

These are all candidates for being scheduled to occur automatically.  

The facility to schedule jobs on your Linux system, is cron.  First, make sure that cron is installed on your system, and running automatically.  Just how this is done, varies depending on the version and dialect of Linux that you are running.

Once cron is installed and running, it is time to schedule some jobs.  This is done with the "crontab -e" command.  This command takes you into the an editor (normally vi or vim) for your cron tables, which is what cron uses to determine what is to be run and the run schedule. When you exit the editor, the running cron is updated with your changes.  It is best to use the crontab editor because, If you edit the cron tables directly, it may not pick up your changes until cron is restarted, typically the next time you reboot.

The editor that is used by the crontab command, is the one identified by your EDITOR environment variable.  You should be familiar with it before you try to change the cron entries.  Assuming it is vi or vim, you can read the man pages for this utility with "man vim".  For a vim tutorial the "vimtutor" command can be used as well. 

Each line in the cron table, is a command to be run at a specific time.  The exception to this is lines beginning with the pound sign (#), which are comments.
 

  • There are basically six fields, separated by spaces. 
  • The first five are define when to run and are the minute, hour, day of the month, month, and day of the week.  Any of these may be "*", which means "all".  So, a line beginning with "* * * * *" would run each minute, hour, day, etc. 
  • To run at specific times, these fields would have numbers in them.  This can be a single number, a list of numbers separated by a comma, or a range.  A range is identified by a dash (-).

To run at the top of the hour, you would use "0" for the minute field. To run at 15 and 45 minutes after the hour, you would use "15,45", and to run each of the first five minutes of the hour, "1-5".  These numbers would be put in without the quotes.

The range for minutes is 0-59, for hours is 0-23, day of the month 1-31, month 1-12, and day of the week 0-6 (with 0 being Sunday).

So, to run a task at 4:15 PM, the first and the 15th of a month, the command would be "15 16 1,15 * * command".  At noon every Friday would be "0 12 * * 5 command".

The command field is everything following the day of the week entry.  This can be any executable Linux command.  Typically, it is a shell script, containing the commands to be executed.  If it is a shell script, make sure that the permissions are set with the execute (x).

Any output will be sent via email to the user for that cron table.  I usually prefer to redirect the output to a log file, instead.  First, I redirect any errors to the standard output, using 2>&1.  Then, I redirect and append the output to a log file, using double greater than (>>).

Put it all together, and you have an entry like:
      15 16 1,15 * * command 2>&1 >> /var/log/command.log 

This runs the command "command", on the first and fifteenth of every month.  Errors are redirected to standard output, and standard output is appended to the file "/var/log/command.log".

This is a quick introduction to cron.  If you need help creating cron scripts and scheduling them with crontab contact us at CCS Retail Systems.

 


Last Updated on Wednesday, 18 January 2012 19:16  
Privacy Policy | CCS Sales | CCS Support | CCS Training | CCS Administration | Author Help | CCS Webmaster | Site Map

© Copyright 2012, CCS Retail Systems, Inc. All Rights Reserved.

Customer Connect Marketing

Customer Connect Video and Details The Only Email Marketing Tool Built for Retailers

Customer Connect (CC) is Loaded With The Features And Functionality Needed For RetailersFully integrated with CounterPoint V7 and CounterPoint SQL, Customer Connect gives you the data needed to effectively connect with your customers, drive sales and increase customer loyalty.

New CustomerConnect Features!

Subscribe to CCS Specials Newsletter.  To unsubscribe use the link at the bottom of a newsletter. CCS Newsletter Sign-up

Visit CCS CustomerConnect eNews Archive CCS CustomerConnect eNews Archive

Quick Menu

 

 

 

 

Recovery Act Tax Deductions

"American Recovery and Reinvestment Act has officially extended the Section 179 Tax Deduction increases for the 2011 Tax Year"

Section 179 can be extremely profitable to you, so it is to your benefit to learn as much as possible. To begin, you probably have a lot of questions regarding Section 179. Follow the links below to get the details on this opportunity:  more ...

 Radiant CounterPoint POS

Radiant Introduces NEW CounterPoint POS Releases

This New 8.3.9 Release of CounterPoint was developed to give retailers New Features and Functions that increase profitability, and ensure a rapid return on investment.

Contact your CCS Sales Consultant to discuss all the new features and functions included.  Ask how they will Keep the Checkouts moving, the Inventory Optimized, and the Back-office Managed. Here are just a few of CounterPoint 8.3.9’s enhancements:  

♦ Registry/Wish List ♦ Message Center
♦ Margin Driven Pricing ♦ Miscellaneous Kits
♦ Tag-Along Kits ♦ Scrap Items
♦ Inactive Items ♦ Discount Overrides
♦ Item Zoom ♦ Forecasted Advices
♦ Enhanced Advices ♦ Work Center
♦ PCI DSS Passwords ♦ Enhanced CC Security

CPSQL 8.4.0 is on its way. Check out What's Coming with the link below!

CPSQL 8.4.0  | CP V7.5.19  | Product News | POS Stations

Why Choose CPSQL?

We have selected two dozen Recent New Retail CounterPoint SQL POS Customers to Profile for you. 

We suspect that you may have Needs Similar to theirs.  See Why these Retailers chose CPSQL and What they Found to be the Benefits.   more ...

Is Your System Healthy?

Great Deals!  New and Refurbished Systems.  Netbooks, Notebooks, Desktops, Servers, Storage Systems, Retail Devices.  Configure your own Systems for us to install.  more ...

Topic Cloud

GeoIP Location

Bookmark Us

Add to: JBookmarks Add to: Facebook Add to: Buzka Add to: Windows Live Add to: Ximmy Add to: Bookmarks.cc Add to: Linkarena Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: Jumptags Add to: Upchuckr Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Blogmarks Add to: Diigo Add to: Technorati Add to: Newsvine Add to: Blinkbits Add to: Ma.Gnolia Add to: Smarking Add to: Spurl Add to: Google Add to: Blinklist Information

Spam Free



Translate Page




Dave's Blog Newsfeed Subscribe to FeedBurner

Products and Services

 
Product Details
 
 
 

CCS Customer Comments

Customer Referrals

CCS offers rewards for each new, verified Prospect referral. We encourage you to think of the value that CounterPoint has added to your business and share that with others who will also benefit.

Submit a ReferralSubmitReferral

Get Involved In Our Site!

Become an Author.We encourage our customers, suppliers, and friends to participate in our site.  See the Visitor Services pages for details.