PowerScale OneFS: How to Edit Crontab
Zusammenfassung: Crontab is a utility used for Task Scheduling and Task Automation.
Weisungen
Procedure
View the crontab files.
Run the appropriate command to view the cluster wide c (including additions from local node's specific) crontab file.
For cluster wide:
cat /etc/crontab
For just the local node crontab additional entries (that get added to /etc/crontab only on specific node):
cat /etc/local/crontab.local
cron jobs, which is appropriate for a job such as TreeDelete, the /etc/local/crontab.local file must be created. See below for more information.
OneFS generates the /etc/crontab file by combining the default template, /etc/mcp/override/crontab and /etc/local/crontab.local. A sample crontab entry is displayed below.
#minute hour mday month wday who command # # Nightly Health check update 0 1 * * * root /usr/bin/isi_healthcheck_update -s
The following table explains the column headers:
|
Header name |
Allowed value |
Allowed special characters |
|---|---|---|
|
minute |
0-59 |
|
|
hour |
0-23 |
|
|
mday |
day of month, 1-31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This table explains the special characters:
|
Special character |
Definition |
|---|---|
|
|
Asterisks are used to indicate the |
|
|
Slashes are used to describe increments of ranges. For example, |
|
|
Percent signs are changed into newline characters in commands. |
|
|
Commas are used to separate items of a list. For example, THU, FRI, SAT |
|
|
Hyphens are used to define ranges, such as 200-205. |
|
|
Stands for "last." Used with the day-of-week field to specify constructs such as "last Friday" which would be 5L. |
|
|
Used for the day-of-month field, to specify a weekday nearest the given day. For example, 14W would be the nearest weekday to the 14th of the month. |
|
|
Used for day-of-week field and followed by a number between 1 and 5 to specify constructs such as the second Monday of a given month. |
|
|
Used instead of * for leaving day-of-month or day-of-week blank |
/etc/crontab file, instructions are given on where to add entries or make changes for customization. The /etc/local/crontab.local file and the /etc/mcp/override/crontab file is initially user-created so it does not have instructions.
Editing the crontab files.
Whenever possible, you should use a client and the API to effect scheduled jobs on the cluster. Directly adding crontab entries should be a last resort and must be verified to not cause disruption, instability or otherwise impact the cluster.
If there is a need for custom cronjobs, first discuss with your account team for creation of a feature request.
/etc/crontab file must NOT be edited directly.
Adding entries or modifying entries to this file must be done in the
/etc/mcp/override/crontab file for cluster wide and the /etc/local/crontab.local for local node.
Crontab entries in
/etc/mcp/override/crontab file (cluster wide) and the /etc/local/crontab.local are preserved during updates.
If the /etc/local/crontab.local file does not exist, use the command below to create:
touch /etc/local/crontab.local
Similarly, if the /etc/mcp/override/crontab file does not exist, use the command below to create:
touch /etc/mcp/override/crontab
crontab file, make a backup of the file so that it can be restored if necessary:
cp /etc/local/crontab.local /etc/local/crontab.local.backup
An entry can be added directly by running the following command:
vi /etc/local/crontab.local
And similarly:
vi /etc/mcp/override/crontab
Paste or type the required entry as shown in the below example:
To add treedelete.sh to run at 11 PM daily:
0 23 * * * root /bin/sh /ifs/data/Scripts/treedelete.sh
Using isi_ropc in crontab entries
Adding isi_ropc to a crontab entry runs the passed command at most once per cluster per version no matter how many nodes it is run on. Without a flag, this would allow the command to run on the node with the lowest DevID. Alternatively, adding the -s flag would run the command on a random node. An example entry is below:
# rotate log files on /ifs, too -- one node per cluster at a time
15,45 * * * * root isi_ropc newsyslog -f /etc/newsyslog.ifs.conf
Add multiple entries to a crontab file.
If a crontab file requires multiple entries from another file, append the job entry. This example where path_to_file_with_entries is the file that contains the entries to be imported:
cat /ifs/<path_to_file_with_entries> >> /etc/local/crontab.local
Verify entries are propageted correctly to the system's crontab file.
Output similar to the following is displayed at the bottom of the output:
tail -n 50 /etc/crontab # X: ---------------- # X: OVERRIDE# X: This section contains user changes which will be # X: preserved between product versions. It is # X: populated from the contents of the file # X: /etc/mcp/override/crontab # X: ---------------- # X: ---------------- # X: LOCAL # X: This section contains entries local to this node # X: only. This section is populated from the contents of # X: the file /etc/local/crontab.local if it exists. # X: ----------------0 23 * * * root /bin/sh /ifs/data/Scripts/treedelete.sh
Revert changes to the crontab file:
These steps revert the crontab.local file to the backup version that were created in the previous section.
- Open an
SSHconnection on any node in the cluster and log in using the root account. - Run the following command to copy and then rename the original backup of the
crontab.localfile:
cp /etc/local/crontab.local.backup /etc/local/crontab.local
Weitere Informationen
Prior to OneFS 9.5, /etc/mcp/override/crontab.smbtime was used to preserve entries through upgrades. It has since been determined that beginning with OneFS 9.5 and later, use /etc/mcp/override/crontab instead of /etc/mcp/override/crontab.smbtime.