The try-later Script

Valid for versions 82 through the latest version

Version:

82


Last modified: July 28, 2022

Overview

The /usr/local/cpanel/scripts/try-later script runs a user-defined check command at a specified interval to verify if it can run a user-defined action command. If the user-defined check command returns an error, the script will retry the command a specified number of times. When the user-defined check command succeeds, the script will run the user-defined action command. If the user-defined check command fails the maximum number of retries, the script will perform an act-finally command.

Run the script

To run this script on the command line, use the following format:

/usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/scripts/try-later [options]
Important:
  • You must call the /usr/local/cpanel/3rdparty/bin/perl Perl directory before the script command.
  • You can use Bash commands with this script (for example, the -x executable command).
  • For an example of this command, see the Example section below.

Options

Use the following options with this script:

Option
Description Example
--action Required.
When the check command succeeds, the script will run the action command.
--action /usr/local/cpanel/scripts/enable_spf_dkim_globally
--check Required.
The script runs this command to determine whether to perform the action command.
--check /bin/sh
--act-finally If the check command fails the maximum number of retries, the script performs this command. --act-finally 0
--at The script will run the check command at the specified time. For more information, read Linux’s at manual entry. --at now + 12 minutes
--delay The script will pause for this number of minutes before it performs each check and action command.
Note:
This option overrides the --at option.

This value defaults to 5.
--delay 1
--has-jobs The script will indicate whether its queue is empty or not. --has-jobs
--max-retries The script will attempt to run the check command this number of times. --max-retries 1
--skip-first The script will skip the first check command. --skip-first
--help Display the script’s help documentation. --help

Example

The following example calls the /usr/local/cpanel/scripts/enable_spf_dkim_globally script with this script at the now + 1 minute interval. If it succeeds, it will run the /usr/local/cpanel/scripts/enable_spf_dkim_globally script:

/usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/scripts/try-later --action /usr/local/cpanel/scripts/enable_spf_dkim_globally -x --max-retries 1 --delay 1 --check /bin/sh -c exit 1 --at now + 1 minute --act-finally 0

Additional Documentation