3 questions

Automation, Orchestration & Scripting

In a bash script, which variable holds the exit status of the most recently executed command?

  • a.$0
  • b.$?✓
  • c.$!
  • d.$#

'$?' contains the exit status of the last command, where 0 means success and non-zero indicates an error. '$#' is the argument count, '$!' is the PID of the last background job, and '$0' is the script name.

Automation, Orchestration & Scripting

Which cron schedule expression runs a job every day at 2:30 AM?

  • a.30 2 * * 0
  • b.* 2 30 * *
  • c.30 2 * * *✓
  • d.2 30 * * *

Cron fields are minute, hour, day-of-month, month, day-of-week, so '30 2 * * *' means minute 30 of hour 2 every day. '30 2 * * 0' would restrict it to Sundays, and the other orderings misplace the minute and hour fields.

Automation, Orchestration & Scripting

In Ansible, which characteristic describes a well-written task that can run repeatedly without changing the result after the first successful run?

  • a.Stateful
  • b.Ephemeral
  • c.Imperative
  • d.Idempotent✓

Idempotency means applying the same task multiple times yields the same end state, so Ansible only makes changes when the system differs from the desired state. This is a core principle of infrastructure-as-code that prevents unintended repeated modifications.

Report