Cron Jobs

Cron jobs are used in automating the scheduled tasks in linux.

Scheduling

Crontab is a Linux utility used for scheduling the timely scheduled tasks.

Scheduling With Crontab

  • Repeated tasks may be scheduled with the crontab command

  • crontab –e will edit the current user‘s crontab with the default editor.

  • Comments can be put into the crontab with the #.

Scheduling One-Time Tasks

Use at for one-time tasks which need to be run off-hours or at a specific time. at can easily schedule jobs to run at a specific time today, tomorrow, or on a specified date and time. If you would like an email when the job completes, regardless of output just add the –m flag.

Run a script at 11:30 pm today

$at 23:30 at>/u01/oracle/scripts/hot_backup.sh at> ctrl+d <EOT>
job 5 at 2008-12-25 23:30

Run at 11:00 am tomorrow and email when complete: $at –m 11:00 tomorrow

at> /u01/oracle/scripts/hot_backup.sh
at> ctrl+d <EOT>
job 6 at 2008-12-28 11:00

Signals

A signal is a report to your process about a specific condition.

Some of shell Signals. (Signal numbers may be different in your system.)

Signal NumberNameMeaning
1Hang upTerminal connection is lost
2InterruptOne of the interrupt keys has been pressed
3quitOne of the quit keys has been pressed
9killThe kill -9 command has been issued
15TerminatorThe kill command has been issued

Hang up and Interrupt Signals

Hang up and Interrupt Signals are used in Linux to gracefully interrupt the Linux processes.

Hang Up Signal

This signal is generated when the cord that runs from your terminal to the computer is disconnected, or when the phone line (your modem connection) is lost.

Interrupt Signals

This signal is generated when one of the interrupt keys is pressed. This could be [Del], [Break], or [Ctrl-c].

Quit and Kill Signals

Quit and Kill Single are used in Linux to halt the Linux processes.

Quit Signal

This signal is generated from your keyboard when you press [Ctrl-]. This causes the process to core dump before it terminates. (A core dump file is produced when your executable program encounters an error. This file is a copy of the memory image of your running program taken right after the error.)

Kill Signals

Signal 9 and 15 are generated by the kill command. Signal 15 is the default signal, and 9 is generated when the kill command option -9 is used. (Some processes protect themselves from the kill signals, you must use the signal 9 (sure kill) to terminate these.)

Subscribe For More Content