Book Image

Learning Linux Shell Scripting

By : Ganesh Sanjiv Naik
Book Image

Learning Linux Shell Scripting

By: Ganesh Sanjiv Naik

Overview of this book

Linux is the one of the most powerful and universally adopted OSes. Shell is a program that gives the user direct interaction with the operating system. Scripts are collections of commands that are stored in a file. The shell can read this file and act on the commands as if they were typed on the keyboard. Shell scripting is used to automate day-to-day administration, and for testing or product development tasks. This book covers Bash, GNU Bourne Again SHell, preparing you to work in the exciting world of Linux shell scripting. We start with an introduction to the Shell environment and explain basic commands used in Shell. Next we move on to check, kill, and control the execution of processes in Linux OS. Further, we teach you about the filter tools available in Linux and explain standard output and standard errors devices. Then we will ensure you understand Shell’s interpretation of commands and get a firmer grasp so you use them in practice. Next, you’ll experience some real-world essentials such as debugging and perform Shell arithmetic fluently. Then you’ll take a step ahead and learn new and advanced topics in Shell scripting, such as starting up a system and customizing a Linux system. Finally, you’ll get to understand the capabilities of scripting and learn about Grep, Stream Editor, and Awk.
Table of Contents (20 chapters)
Learning Linux Shell Scripting
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding "at"


Many a times we need to schedule a task for a future time, say in the evening at 8 P.M. on a specific day. We can use the at command in such a situation.

Sometimes we need to repeat the same task at a specific time, periodically, every day, or every month. In such situations, we can use the crontab command.

Let's learn more about the utility of the at command. To use the at command, the syntax is as follows:

$ at time date

The following are the examples of the at command:

  • The Control + D command will save the at job. The task will be executed at 11.15 A.M. This command will log messages to the log.txt file at 11.15 A.M.:

    $ at 11.15 AM
    at >  echo "Hello World" > $HOME/log.txt
    at >  Control + D
    
  • The following command will send an e-mail on March 31, 2015 at 10 A.M.:

    $ at 10am mar 31 2015
    at> echo "taxes due" | mail jon
    at> ^D
    
  • The following command will make the task run on May 20 at 11 A.M.:

    $ at 11 am may 20
    
  • All the jobs which are scheduled by the at command...