MCQs on Scheduling and Automation | Shell Scripting

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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. Which of the following symbols is used to represent “every” in Cron expressions?
    a) *
    b) .
    c) #
    d) &
  8. 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
  9. 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
  10. 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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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/
  7. Which option is used with the at command to specify the time zone?
    a) -t
    b) -z
    c) -u
    d) -T
  8. 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
  9. 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
  10. 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

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. Which of the following is a commonly used command for scheduling automated backups?
    a) rsync
    b) cp
    c) tar
    d) cron
  7. 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
  8. 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
  9. 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
  10. 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

QnoAnswer
1a) To schedule tasks to run automatically at specific intervals
2a) crontab -e
3c) /var/spool/cron/crontabs
4b) hour minute day month weekday command
5a) Every day at 5:00 AM
6a) crontab -l
7a) *
8a) 0 10 * * 1 command
9a) crontab -r
10a) System default time zone
11a) To schedule tasks at a specific time once
12a) at 10:00 command
13a) at -r job_id
14a) It schedules tasks to run when system load is low
15a) `echo “command”
16a) /var/spool/atjobs
17d) -T
18c) `echo “command”
19b) The job will be logged as a failed attempt
20a) atq
21c) To automate routine system tasks
22a) Use Cron Jobs to schedule the script
23b) It specifies the environment for running the script
24a) By defining variables within the script
25a) To delay the execution of a command or script
26a) rsync
27a) A job ID
28a) By writing a shell script and scheduling it with Cron
29a) Create a Cron Job to run logrotate
30a) read command

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top