Learn how to schedule tasks efficiently using Cron Jobs, the at and batch commands, and automate processes with shell scripts to improve productivity and system management in Linux environments.
MCQs on Scheduling and Automation
1. Introduction to Cron Jobs
What is the purpose of Cron Jobs in Linux? a) To schedule tasks to run automatically at specific intervals b) To back up system files c) To monitor system performance d) To manage user permissions
What command is used to edit the Cron Jobs for a specific user? a) crontab -e b) cron -e c) crontab -u d) edit cron
What is the file that stores the scheduled Cron Jobs? a) /etc/crontab b) /etc/cron.d/ c) /var/spool/cron/crontabs d) /cron_jobs
Which of the following is the correct syntax for a Cron Job? a) minute hour day month weekday command b) hour minute day month weekday command c) minute hour day month weekday action d) hour minute second day month command
What does the Cron Job expression 0 5 * * * signify? a) Every day at 5:00 AM b) Every day at 5:00 PM c) At 5 minutes past 5:00 AM daily d) At 5 PM every first day of the month
How can you view the list of Cron Jobs scheduled for the current user? a) crontab -l b) cron -list c) crontab -view d) view cron_jobs
Which of the following symbols is used to represent “every” in Cron expressions? a) * b) . c) # d) &
How would you schedule a Cron Job to run every Monday at 10 AM? a) 0 10 * * 1 command b) 10 0 * * 1 command c) 0 10 1 * * command d) 10 0 1 * * command
What command would you use to remove all Cron Jobs for the current user? a) crontab -r b) cron -delete c) crontab -remove d) remove cron_jobs
What is the default time zone for Cron Jobs? a) System default time zone b) UTC c) GMT d) Local time zone
2. Using at and batch Commands
What is the purpose of the at command in Linux? a) To schedule tasks at a specific time once b) To schedule tasks repeatedly c) To schedule backup jobs d) To list Cron Jobs
Which command is used to schedule a one-time task using at? a) at 10:00 command b) at -e command c) at run command d) at schedule command
How do you cancel a scheduled at job? a) at -r job_id b) at cancel job_id c) at -d job_id d) at delete job_id
What does the batch command do in Linux? a) It schedules tasks to run when system load is low b) It schedules tasks for the current day c) It executes tasks based on available memory d) It schedules tasks in a batch job
How would you schedule a job to run in 5 minutes using at? a) echo "command" | at now + 5 minutes b) at 5 minutes command c) at 5m command d) at now - 5 minutes command
Which file contains the list of scheduled at jobs for all users? a) /var/spool/atjobs b) /etc/at.d/ c) /var/spool/cron/atjobs d) /etc/atjobs/
Which option is used with the at command to specify the time zone? a) -t b) -z c) -u d) -T
What is the correct syntax to use batch to schedule a job? a) batch command b) batch -e command c) echo "command" | batch d) batch run command
What happens if a job scheduled with at is not executed? a) The job will be retried immediately b) The job will be logged as a failed attempt c) The job will be lost d) The job will be rescheduled automatically
What command would you use to list the pending jobs in at queue? a) atq b) at-list c) atjobs d) at -l
3. Automating with Scripts
What is the purpose of using shell scripts for automation? a) To manually execute repetitive tasks b) To simplify complex commands c) To automate routine system tasks d) To debug other scripts
How can you make sure a script runs at a specific time every day? a) Use Cron Jobs to schedule the script b) Use the at command c) Manually run the script every day d) Schedule the script using batch
What is the benefit of using the #!/bin/bash line in an automation script? a) It defines the time zone for the script b) It specifies the environment for running the script c) It adds comments for the script’s function d) It ensures the script runs as an executable file
How would you pass parameters to a shell script automatically in Cron? a) By defining variables within the script b) By using Cron’s @reboot command c) By passing arguments directly in Cron expression d) By modifying the system’s PATH variable
What is the purpose of using the sleep command in automation scripts? a) To delay the execution of a command or script b) To terminate a process c) To pause for user input d) To stop the entire script from running
Which of the following is a commonly used command for scheduling automated backups? a) rsync b) cp c) tar d) cron
What does the at command return after successfully scheduling a task? a) A job ID b) A confirmation message c) The status of the system d) A timestamp
How can you automate system monitoring tasks in Linux? a) By writing a shell script and scheduling it with Cron b) By manually checking system logs c) By installing monitoring software d) By using GUI tools
What is the best practice for automating the cleanup of old logs in Linux? a) Create a Cron Job to run logrotate b) Run logrotate manually every week c) Use the at command for log cleanup d) Write a script to delete logs on a regular basis
Which shell feature is most commonly used in automation to read user input? a) read command b) echo command c) input function d) prompt function
Answers
Qno
Answer
1
a) To schedule tasks to run automatically at specific intervals
2
a) crontab -e
3
c) /var/spool/cron/crontabs
4
b) hour minute day month weekday command
5
a) Every day at 5:00 AM
6
a) crontab -l
7
a) *
8
a) 0 10 * * 1 command
9
a) crontab -r
10
a) System default time zone
11
a) To schedule tasks at a specific time once
12
a) at 10:00 command
13
a) at -r job_id
14
a) It schedules tasks to run when system load is low
15
a) `echo “command”
16
a) /var/spool/atjobs
17
d) -T
18
c) `echo “command”
19
b) The job will be logged as a failed attempt
20
a) atq
21
c) To automate routine system tasks
22
a) Use Cron Jobs to schedule the script
23
b) It specifies the environment for running the script
24
a) By defining variables within the script
25
a) To delay the execution of a command or script
26
a) rsync
27
a) A job ID
28
a) By writing a shell script and scheduling it with Cron