SlideShare a Scribd company logo
Job Automation Using
Linux
Cron and At
 Cron is a deamon called "crond" used to schedule and execute jobs
or scripts automatically without user intervention. Cron, also
referred to as crontab, can help with automated log rotation,
scheduled reporting and running of scripts at off times of the day.
Cron is primarily used for jobs needing to be executed over and over
like log rotation every week or a report email sent out every
morning.
 An addtitional tool one can use is called "at" and is used to execute
a job only once. "at" is very useful, for example if you want run a
backup job starting at 8pm and you expect to be leaving at 5:30pm.
 In OpenBSD and FreeBSD the daemon cron can handel cron jobs as
well at "at" jobs. In Linux the "crond" daemon is used for cron jobs
only and a separate daemon "atd" is used for at jobs. Make sure the
correct daemon is running for the job scheduler you are looking to
use.
To use cron tab there are two important commands:
 crontab -e edit your crontab entries
 crontab -l print the entries from crontab
 Here is an example of a very easy to reference header for your
crontab. You have the descriptions for every time slot and what every
slot will accept. This example also specifies the shell and the path
making sure the binaries you run can be found. The last line is an
example of running "newsyslog" Sunday at midnight. You are welcome
to cut/paste this block to the top of your cron tab.
Lets take a look at some examples in order of simple to alittle more
complex. Notice all of the binaries are using their absolute paths. Cron
uses its own PATH variable and it is a safe practice to always use absolute
paths in your crontab. This is to avoid confusion.
Rotate logs weekly at 12midnight. (just like the example above)
00 0 * * 0 /usr/bin/newsyslog
Rotate logs weekly at 12midnight. (instead of 0 for the day of the week
we can use Sun for Sunday)
00 0 * * Sun /usr/bin/newsyslog
Mail a report to root everyday at 11:59pm (23:59).
59 23 * * * /usr/local/bin/pflogsumm -d today /var/log/maillog | mail -s "mail
report" root
 Run the backup scripts at 5am on the 3rd (Wed) and 5th (Fri) day of the week.
Send any errors to /dev/null
 00 5 * * 3,5 /tools/BACKUP_script.sh >> /dev/null 2>&1
 Compress backup files at 6am on the 1st and 15th of the month.
 00 6 1,15 * * /tools/BACKUP_compress.sh
 Refresh the Squid ad blocker server list every 3 days at 12:05am.
 05 0 * * */3 /tools/ad_servers_newlist.sh
 Clear the blocked hosts list at 3:23pm (15:23) every Monday only on even
numbered months.
 23 15 * */2 1 /tools/clear_blocked_hosts.sh
 Run a script at 8:45pm (20:45) on 2nd and the 16th only in the months of
January and April.
45 20 2,16 1,4 * /tools/a_script.sh
 Run a script every day at 8:45pm (20:45) and add a random sleep time
between 0 and 300 seconds.
45 20 * * * sleep $(($RANDOM % 300)); /tools/a_script.sh
 Run the script at 23:59 (11:59pm) on the last day of the month.
59 23 28-31 * * [ $(date -d +1day +%d) -eq 1 ] && /tools/a_script.sh
 To run jobs only once it is easier to use "at" than to setup and cron job and
then go back and remove it once the job has ran. Remember you need to
have the "atd" daemon running on Linux systems to run "at" jobs. On OpenBSD
or FreeBSD system the "crond" daemon will handle "cron" and "at" jobs.
 To run an "at" job you need to fist tell "at" what time to run the job.
Remember to use absolute paths to avoid confusion. Once to execute att with
the time and date you will be put into an "at" shell. This is where you will
enter the commands you want to execute, one command per line to make it
simple.
 In this example we will be executing a set of commands at 5am on January
23rd. The backup script will run and then we will send out mail to root. To
close the "at" shell and save the job you must type Ctrl-d (the control key
with the lowercase d).
Job Automation using Linux

More Related Content

What's hot

Linux file system
Linux file systemLinux file system
Linux file system
Md. Tanvir Hossain
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.ppt
Rakesh Kadu
 
Mail server on linux
Mail server on linux Mail server on linux
Mail server on linux
Roshni17
 
Cron
CronCron
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
Bhavesh Padharia
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Jian-Hong Pan
 
Linux Networking Commands
Linux Networking CommandsLinux Networking Commands
Linux Networking Commands
tmavroidis
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Geeks Anonymes
 
Linux and DNS Server
Linux and DNS ServerLinux and DNS Server
Linux and DNS Server
Prabhakar Thota
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
Kernel TLV
 
Linux file system
Linux file systemLinux file system
Linux file system
Midaga Mengistu
 
Linux distributions
Linux    distributionsLinux    distributions
Linux distributions
RJ Mehul Gadhiya
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
Ramasubbu .P
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
Goutam Sahoo
 
Intro to linux
Intro to linuxIntro to linux
Intro to linux
Ravi Prakash Giri
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
Thomas Petazzoni
 
Presentation on linux
Presentation on linuxPresentation on linux
Presentation on linux
Veeral Bhateja
 

What's hot (20)

Linux file system
Linux file systemLinux file system
Linux file system
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.ppt
 
Mail server on linux
Mail server on linux Mail server on linux
Mail server on linux
 
Cron
CronCron
Cron
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Linux crontab
Linux crontabLinux crontab
Linux crontab
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
Linux Networking Commands
Linux Networking CommandsLinux Networking Commands
Linux Networking Commands
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux and DNS Server
Linux and DNS ServerLinux and DNS Server
Linux and DNS Server
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux distributions
Linux    distributionsLinux    distributions
Linux distributions
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Intro to linux
Intro to linuxIntro to linux
Intro to linux
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
 
Presentation on linux
Presentation on linuxPresentation on linux
Presentation on linux
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 

Viewers also liked

Processor grafxtron
Processor grafxtronProcessor grafxtron
Processor grafxtron
Smart Equipments
 
Building Linux IPv6 DNS Server (Complete Soft Copy)
Building Linux IPv6 DNS Server (Complete Soft Copy)Building Linux IPv6 DNS Server (Complete Soft Copy)
Building Linux IPv6 DNS Server (Complete Soft Copy)
Hari
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Linux Beginner Guide 2014
Linux Beginner Guide 2014Linux Beginner Guide 2014
Linux Beginner Guide 2014
Anthony Le Goff
 
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Joachim Jacob
 
Apa itu Debian dan Bagaimana Cara Installnya?
Apa itu Debian dan Bagaimana Cara Installnya?Apa itu Debian dan Bagaimana Cara Installnya?
Apa itu Debian dan Bagaimana Cara Installnya?
Rizky Hidayat
 
Debian jessie
Debian jessieDebian jessie
Debian jessie
Helio Loureiro
 
Linux beginner's Workshop
Linux beginner's WorkshopLinux beginner's Workshop
Linux beginner's Workshop
futureshocked
 
Linux server administration for non expert users
Linux server administration for non expert users Linux server administration for non expert users
Linux server administration for non expert users
Alessio Fattorini
 
A minor project report HOME AUTOMATION USING MOBILE PHONES
A minor project report HOME AUTOMATION  USING  MOBILE PHONESA minor project report HOME AUTOMATION  USING  MOBILE PHONES
A minor project report HOME AUTOMATION USING MOBILE PHONES
ashokkok
 
Ubuntu – Linux Useful Commands
Ubuntu – Linux Useful CommandsUbuntu – Linux Useful Commands
Ubuntu – Linux Useful Commands
University of Technology
 
Presentation Smart Home With Home Automation
Presentation Smart Home With Home AutomationPresentation Smart Home With Home Automation
Presentation Smart Home With Home Automation
Arifur Rahman
 
Home automation using android mobiles
Home automation using android mobilesHome automation using android mobiles
Home automation using android mobiles
Durairaja
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
iimjobs and hirist
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
elliehood
 

Viewers also liked (16)

Processor grafxtron
Processor grafxtronProcessor grafxtron
Processor grafxtron
 
Building Linux IPv6 DNS Server (Complete Soft Copy)
Building Linux IPv6 DNS Server (Complete Soft Copy)Building Linux IPv6 DNS Server (Complete Soft Copy)
Building Linux IPv6 DNS Server (Complete Soft Copy)
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Embedded Linux On A R M
Embedded  Linux On  A R MEmbedded  Linux On  A R M
Embedded Linux On A R M
 
Linux Beginner Guide 2014
Linux Beginner Guide 2014Linux Beginner Guide 2014
Linux Beginner Guide 2014
 
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
 
Apa itu Debian dan Bagaimana Cara Installnya?
Apa itu Debian dan Bagaimana Cara Installnya?Apa itu Debian dan Bagaimana Cara Installnya?
Apa itu Debian dan Bagaimana Cara Installnya?
 
Debian jessie
Debian jessieDebian jessie
Debian jessie
 
Linux beginner's Workshop
Linux beginner's WorkshopLinux beginner's Workshop
Linux beginner's Workshop
 
Linux server administration for non expert users
Linux server administration for non expert users Linux server administration for non expert users
Linux server administration for non expert users
 
A minor project report HOME AUTOMATION USING MOBILE PHONES
A minor project report HOME AUTOMATION  USING  MOBILE PHONESA minor project report HOME AUTOMATION  USING  MOBILE PHONES
A minor project report HOME AUTOMATION USING MOBILE PHONES
 
Ubuntu – Linux Useful Commands
Ubuntu – Linux Useful CommandsUbuntu – Linux Useful Commands
Ubuntu – Linux Useful Commands
 
Presentation Smart Home With Home Automation
Presentation Smart Home With Home AutomationPresentation Smart Home With Home Automation
Presentation Smart Home With Home Automation
 
Home automation using android mobiles
Home automation using android mobilesHome automation using android mobiles
Home automation using android mobiles
 
Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014Top 100 Linux Interview Questions and Answers 2014
Top 100 Linux Interview Questions and Answers 2014
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
 

Similar to Job Automation using Linux

Example Stream Setup
Example  Stream  SetupExample  Stream  Setup
Example Stream Setup
cfministries
 
Linux talk | scheduled tasks
Linux talk | scheduled tasksLinux talk | scheduled tasks
Linux talk | scheduled tasks
YashwantVarma1
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
Francesco Pantano
 
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docxallscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
galerussel59292
 
exercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdfexercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdf
SngB2
 
Linuxppt
LinuxpptLinuxppt
LinuxpptReka
 
Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with TsungNgoc Dao
 
(Practical) linux 104
(Practical) linux 104(Practical) linux 104
(Practical) linux 104
Arie Bregman
 
Unit 10 investigating and managing
Unit 10 investigating and managingUnit 10 investigating and managing
Unit 10 investigating and managingroot_fibo
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atd
Acácio Oliveira
 
101 apend. scripting, crond, atd
101 apend. scripting, crond, atd101 apend. scripting, crond, atd
101 apend. scripting, crond, atd
Acácio Oliveira
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Maarten Mulders
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Dmitry Ponomarenko
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
Tyler Johnston
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageable
corehard_by
 
2004 ugm-tips-tricks
2004 ugm-tips-tricks2004 ugm-tips-tricks
2004 ugm-tips-tricks
Shamoon Jamshed
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
John Anderson
 

Similar to Job Automation using Linux (20)

Example Stream Setup
Example  Stream  SetupExample  Stream  Setup
Example Stream Setup
 
Linux talk | scheduled tasks
Linux talk | scheduled tasksLinux talk | scheduled tasks
Linux talk | scheduled tasks
 
Introducing Ansible
Introducing AnsibleIntroducing Ansible
Introducing Ansible
 
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docxallscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
allscripts.pdf-----schedule.sh------ #!binbash #ssh .docx
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
exercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdfexercises-log-management-rsyslog.pdf
exercises-log-management-rsyslog.pdf
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Easy distributed load test with Tsung
Easy distributed load test with TsungEasy distributed load test with Tsung
Easy distributed load test with Tsung
 
(Practical) linux 104
(Practical) linux 104(Practical) linux 104
(Practical) linux 104
 
Unit 10 investigating and managing
Unit 10 investigating and managingUnit 10 investigating and managing
Unit 10 investigating and managing
 
3.1.c apend scripting, crond, atd
3.1.c apend   scripting, crond, atd3.1.c apend   scripting, crond, atd
3.1.c apend scripting, crond, atd
 
101 apend. scripting, crond, atd
101 apend. scripting, crond, atd101 apend. scripting, crond, atd
101 apend. scripting, crond, atd
 
Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)Building a DSL with GraalVM (VoxxedDays Luxembourg)
Building a DSL with GraalVM (VoxxedDays Luxembourg)
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)Monitoring CPU Utilization on LINUX (Shell Script Project)
Monitoring CPU Utilization on LINUX (Shell Script Project)
 
Docker - A Ruby Introduction
Docker - A Ruby IntroductionDocker - A Ruby Introduction
Docker - A Ruby Introduction
 
How to make a large C++-code base manageable
How to make a large C++-code base manageableHow to make a large C++-code base manageable
How to make a large C++-code base manageable
 
2004 ugm-tips-tricks
2004 ugm-tips-tricks2004 ugm-tips-tricks
2004 ugm-tips-tricks
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 

More from Jishnu Pradeep

Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
Jishnu Pradeep
 
Cyber Security of Power grids
Cyber Security of Power grids Cyber Security of Power grids
Cyber Security of Power grids
Jishnu Pradeep
 
Secure Data Sharing in Cloud (SDSC)
Secure Data Sharing in Cloud (SDSC)Secure Data Sharing in Cloud (SDSC)
Secure Data Sharing in Cloud (SDSC)
Jishnu Pradeep
 
Telnet
TelnetTelnet
Augmented Reality & Applications
Augmented Reality & ApplicationsAugmented Reality & Applications
Augmented Reality & Applications
Jishnu Pradeep
 
Motherboard and its components
Motherboard and its componentsMotherboard and its components
Motherboard and its components
Jishnu Pradeep
 

More from Jishnu Pradeep (6)

Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
Paper Presentation - "Your Botnet is my Botnet : Analysis of a Botnet Takeover"
 
Cyber Security of Power grids
Cyber Security of Power grids Cyber Security of Power grids
Cyber Security of Power grids
 
Secure Data Sharing in Cloud (SDSC)
Secure Data Sharing in Cloud (SDSC)Secure Data Sharing in Cloud (SDSC)
Secure Data Sharing in Cloud (SDSC)
 
Telnet
TelnetTelnet
Telnet
 
Augmented Reality & Applications
Augmented Reality & ApplicationsAugmented Reality & Applications
Augmented Reality & Applications
 
Motherboard and its components
Motherboard and its componentsMotherboard and its components
Motherboard and its components
 

Recently uploaded

H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 

Recently uploaded (20)

H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 

Job Automation using Linux

  • 2.  Cron is a deamon called "crond" used to schedule and execute jobs or scripts automatically without user intervention. Cron, also referred to as crontab, can help with automated log rotation, scheduled reporting and running of scripts at off times of the day. Cron is primarily used for jobs needing to be executed over and over like log rotation every week or a report email sent out every morning.  An addtitional tool one can use is called "at" and is used to execute a job only once. "at" is very useful, for example if you want run a backup job starting at 8pm and you expect to be leaving at 5:30pm.  In OpenBSD and FreeBSD the daemon cron can handel cron jobs as well at "at" jobs. In Linux the "crond" daemon is used for cron jobs only and a separate daemon "atd" is used for at jobs. Make sure the correct daemon is running for the job scheduler you are looking to use.
  • 3. To use cron tab there are two important commands:  crontab -e edit your crontab entries  crontab -l print the entries from crontab
  • 4.  Here is an example of a very easy to reference header for your crontab. You have the descriptions for every time slot and what every slot will accept. This example also specifies the shell and the path making sure the binaries you run can be found. The last line is an example of running "newsyslog" Sunday at midnight. You are welcome to cut/paste this block to the top of your cron tab.
  • 5. Lets take a look at some examples in order of simple to alittle more complex. Notice all of the binaries are using their absolute paths. Cron uses its own PATH variable and it is a safe practice to always use absolute paths in your crontab. This is to avoid confusion. Rotate logs weekly at 12midnight. (just like the example above) 00 0 * * 0 /usr/bin/newsyslog Rotate logs weekly at 12midnight. (instead of 0 for the day of the week we can use Sun for Sunday) 00 0 * * Sun /usr/bin/newsyslog Mail a report to root everyday at 11:59pm (23:59). 59 23 * * * /usr/local/bin/pflogsumm -d today /var/log/maillog | mail -s "mail report" root
  • 6.  Run the backup scripts at 5am on the 3rd (Wed) and 5th (Fri) day of the week. Send any errors to /dev/null  00 5 * * 3,5 /tools/BACKUP_script.sh >> /dev/null 2>&1  Compress backup files at 6am on the 1st and 15th of the month.  00 6 1,15 * * /tools/BACKUP_compress.sh  Refresh the Squid ad blocker server list every 3 days at 12:05am.  05 0 * * */3 /tools/ad_servers_newlist.sh  Clear the blocked hosts list at 3:23pm (15:23) every Monday only on even numbered months.  23 15 * */2 1 /tools/clear_blocked_hosts.sh
  • 7.  Run a script at 8:45pm (20:45) on 2nd and the 16th only in the months of January and April. 45 20 2,16 1,4 * /tools/a_script.sh  Run a script every day at 8:45pm (20:45) and add a random sleep time between 0 and 300 seconds. 45 20 * * * sleep $(($RANDOM % 300)); /tools/a_script.sh  Run the script at 23:59 (11:59pm) on the last day of the month. 59 23 28-31 * * [ $(date -d +1day +%d) -eq 1 ] && /tools/a_script.sh
  • 8.  To run jobs only once it is easier to use "at" than to setup and cron job and then go back and remove it once the job has ran. Remember you need to have the "atd" daemon running on Linux systems to run "at" jobs. On OpenBSD or FreeBSD system the "crond" daemon will handle "cron" and "at" jobs.  To run an "at" job you need to fist tell "at" what time to run the job. Remember to use absolute paths to avoid confusion. Once to execute att with the time and date you will be put into an "at" shell. This is where you will enter the commands you want to execute, one command per line to make it simple.  In this example we will be executing a set of commands at 5am on January 23rd. The backup script will run and then we will send out mail to root. To close the "at" shell and save the job you must type Ctrl-d (the control key with the lowercase d).