Up: interfaces   [Contents][Index]


12.1 Scheduling jobs for later execution

This section documents the interface to the atd daemon; we may want to read the at(1) manual page. The at service allows a user to schedule commands to be executed at a later time.

This interface is suitable for scripts that define a unique simple policy to schedule commands; example: at each run they schedule a command in a fixed queue, to be executed at a fixed time in the future.

This is good to implement the logic: if a condition does not happen before time T, then execute command C.

Commands declaration

Function: mbfl_at_enable

Declare the intention to use the at interface. Declaring the intention to use a program.

The declared programs are: at, atq, atrm.

Arguments validation

Function: mbfl_at_validate_queue_letter letter

Return true if letter is a valid queue identifier, else return false.

Function: mbfl_at_validate_selected_queue

Return true if the currently selected queue identifier is valid, else print an error message and return false. A false return code means that an internal error has corrupted the module’s state.

Commands scheduling

Function: mbfl_at_select_queue letter

Select and register in an internal state a queue identifier; invoke mbfl_at_validate_queue_letter() to validate the selection.

Function: mbfl_at_schedule command time

Schedule command in the currently selected queue; the script will be executed at time.

If no error occurs: print to stdout the identifier of the scheduled job; the identifier can be used as argument to mbfl_at_drop().

The at command outputs some text (in which the job is embedded) on its stderr channel, so this function redirects stderr to stdout to return the value; this operation conflicts with the use of the “show program” feature of mbfl_program_exec().

command must be a string representing the invocation of an external executable program: it is sent unchanged to the at command. time is the argument to the at command, see the manual page for its description.

Function: mbfl_at_drop identifier

Remove a job; the identifier of a job is unique in all the queues, so this function is not affected by the currently selected queue.

Function: mbfl_at_queue_clean

Remove all the jobs from the currently selected queue.

Inspection

Function: mbfl_at_queue_print_identifiers

Print all the job identifiers in the currently selected queue.

Function: mbfl_at_queue_print_jobs

Print all the job descriptions in the currently selected queue.

Function: mbfl_at_queue_print_queues

Print the letters identifying queues with pending jobs.

Function: mbfl_at_print_queue

Print the currently selected queue letter.


Up: interfaces   [Contents][Index]

This document describes version 3.0.0-devel.0 of Marcos Bash Functions Library.