“The purpose of this assignment is to show your learning to automate scripts that can be used to manage data-related tasks using a Linux tool such as cron”
Scheduling Shell Scripts in Cron
INET3700
Myeongjin(Jin) Kwon
INET 3700 Final assignment – Linux - Crete Automated Bash Data – Related Scripts
Contents and Purpose of this assignment
SCHEDULING AUTOMATED
• Automating interactive applications can save you time when you need to rerun the same application and frustration while you are developing one • You will learn how to schedule shell scripts using a tool called cron • Use materials from Brightspace, from myacm.org, your toolbox or other resources to complete • Set up crontab to automate scripts from the previous assignment – Creating Automated Bash Scripts – Data Related Complete the following instructions: 1. Execute scripts to run on crontab
Use the following resource to help with automating jobs with cron:
https://learning.oreilly.com/library/view/linux-nd- solaris/9781484212547/9781484212554_Ch10.xht ml
2. Set up permissions to allow oracle to use the crontab utility
3. Verify you can access the cron table using oracle
4. Make a backup copy of your cron table once you have added entries to the cron table • Include the backup file in /backups/cron/ 5. Schedule scripts 1 and 2 (from previous assignment) - Be sure to run the script in the background so if the oracle user shutdown that the cron entry will still keep running. - For each cron entry, a message log for each script will be stored in the /logs directory i. Include day, month, year, name of the script on each log file - Use the following cron settings for each script: i. Script 1 • Run every Monday at 4 pm ii. Script 2 • Run only Tues, Wed, Saturday every 30 minutes 6. Provide a list of cron entries into an output file called list_cron 7. Complete in-class marking with Instructor on the assignment due date. 2 INET 3700 Final assignment – Linux - Crete Automated Bash Data – Related Scripts Execute scripts to run on crontab What I made: * 16 * * 1 /scripts/linux/problem1.sh */30 * * * 2,3,6 /scripts/linux/problem2.sh Results 3 INET 3700 Final assignment – Linux - Crete Automated Bash Data – Related Scripts 4 INET 3700 Final assignment – Linux - Crete Automated Bash Data – Related Scripts References[Resources] and studied How to use Cron: https://soooprmx.com/archives/6786 https://learning.oreilly.com/library/view/linux-and- solaris/9781484212547/9781484212554_Ch10.xhtml apt-get install cron crontab -e: Crontab input file – Vi crontab -l: Check the current contents crontab -d: Delete the contents in Crontab Memo /etc /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ Minute – hour – dom (day of month) – month – dow(day of week) – usr – cmd * M - * H - * D(1-31) - * M(1-12) - *dow(Monday to Saturday: 1 – 6. Sunday = 0, 7 * 16 * * 1 root run-parts / etc/cron.weekly # echo “This command is run at 4 pm every Monday” 5 INET 3700 Final assignment – Linux - Crete Automated Bash Data – Related Scripts ## Tue/ Wed/ Saturday – every 30 mins /root/scripts/status_check.sh */30 * * * 2,3,6 /root/scripts/status_check.sh */30 * * * 2,3,6 /root/scripts/status_check.sh >> /var/log/status_check.log 2>&1 # Meaning of 2>&1 1: stdout 2: stderr >: redirection 2>&1: stderr -> stdout redirection = stdout : same processing * * 1 * * rm -rf /var/log/status_check.log 2>&1 30 * * * Mon Wed Sat root cmd 6