Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Linux Shell Scripting

You're reading from   Learning Linux Shell Scripting Unleash the power of shell scripts to solve real-world problems by breaking through the practice of writing tedious code

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785286216
Length 306 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Ganesh Sanjiv Naik Ganesh Sanjiv Naik
Author Profile Icon Ganesh Sanjiv Naik
Ganesh Sanjiv Naik
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Learning Linux Shell Scripting
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started and Working with Shell Scripting FREE CHAPTER 2. Drilling Deep into Process Management, Job Control, and Automation 3. Using Text Processing and Filters in Your Scripts 4. Working with Commands 5. Exploring Expressions and Variables 6. Neat Tricks with Shell Scripting 7. Performing Arithmetic Operations in Shell Scripts 8. Automating Decision Making in Scripts 9. Working with Functions 10. Using Advanced Functionality in Scripts 11. System Startup and Customizing a Linux System 12. Pattern Matching and Regular Expressions with sed and awk Index

Understanding "crontab"


If we need to run a specific task repetitively, then the solution is to use crontab.

The syntax of the command is as follows:

$  crontab    –e

This will open a new editor. The following diagram is the syntax to add tasks. The fields to use for repeating tasks at what time are explained here:

Finally, to save the jobs, use the following:

wq        # save and quite crontab job

The following are a few examples of the crontab command:

  • Use the following command to run a script every 5 minutes, every day:

    5 * * * *      $HOME/bin/daily.job >> $HOME/tmp/out  2>&1
    
  • Use the following command to run 5 minutes after midnight every day:

    5 0 * * *      $HOME/bin/daily.job >> $HOME/tmp/out  2>&1
    
  • Use the following command to run at 2.15 P.M. on the first of every month—the output is mailed to Paul:

    15 14 1 * * *     $HOME/bin/monthly
    
  • Use the following command to run at 10 P.M. on weekdays, send the e-mail to :

    0 22 * *  1-5   sendmail...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images