The chkfile / jobschchkfile command checks the existence of a file, and waits for the file to be created/updated/deleted/resized.
Synopsis
[Windows]
chkfile [-fwait [-sw]] [-fdelete [-sd]] [-fsize|-fupdate] [-i <monitoring interval>] [-a] drive:file name chkfile [-wait|-update[-d:yyyymmdd][-t:hhmm]|-delete] [-i <monitoring interval>] {drive:file name|-file:drive:list file name [-AND|-OR]} chkfile [-z] drive:file name |
[UNIX]
jobschchkfile [-fwait [-sw]] [-fdelete [-sd]] [-fsize|-fupdate] [-i <monitoring interval>] file name jobschchkfile [-wait|-update[-d:yyyymmdd] [-t:hhmm]|-delete] [-i <monitoring interval>] {file name|-file: list file name [-AND|-OR]} jobschchkfile [-z] file name |
Options
-fwait
If the file does not exist, the command waits for it to be created. Nothing is returned if the file exists when the command starts. If the file is confirmed as having been deleted, a value is returned once the file is recreated.
You can combine this option with -fdelete, -fupdate, and -fsize to make the command wait. In this case, a value is returned when any of the conditions is satisfied.
-sw
Specify this option together with -fwait.
If you specify this option and the file exists when the command starts, a value is returned immediately.
-fdelete
If the file exists, the command waits for the file to be deleted. If the file does not exist when the command starts, nothing is returned. If the file is confirmed as having been created, a value is returned once the file is again deleted.
You can combine this option with -fwait, -fupdate, and -fsize to make the command wait. In this case, a value is returned when any of the conditions is satisfied.
-sd
Specify this option together with -fdelete.
If you specify this option and the file does not exist when the command starts, a value is returned immediately.
-fupdate
If the file exists, the command waits for the update date to be changed. If the file does not exist when the command starts, nothing is returned even if the file is created. If the file is confirmed as having been created, a value is returned once the update date is subsequently confirmed as having been changed.
You can combine this option with -fwait and -fdelete to make the command wait. In this case, a value is returned when any of the conditions is satisfied. You cannot combine this option with -fsize.
-fsize
The command waits for the file size to be changed. Nothing is returned if the file is created or deleted. If the file is updated but there is no change in size, nothing is returned. To make the command wait for the file to be updated without any change in size, use -fupdate.
You can combine this option with -fwait and -fdelete to make the command wait. In this case, a value is returned when any of the conditions is satisfied. You cannot combine this option with -fupdate.
-wait
If the file does not exist, the command waits for it to be created. If the file exists when the command starts, a value is returned immediately.
You cannot combine this option with -delete, -update, -fwait, -fdelete, -fupdate, or -fsize to make the command wait.
-delete
If the file exists, the command waits for the file to be deleted. If the file does not exist when the command starts, a value is returned immediately.
You cannot combine this option with -wait, -update, -fwait, -fdelete, -fupdate, or -fsize to make the command wait.
-update
If the file does not exist, the command waits for it to be created.
If the file exists, the command waits for the update date to be changed.
You cannot combine this option with -wait, -delete, -fwait, -fdelete, -fupdate, or -fsize to make the command wait.
-d:yyyymmdd
Specify this option together with -update.
Specify the reference date to be used to determine if the file was updated.
For example, for June 5 2014, specify -d:20140605.
If this option is omitted, the current date or later is assumed.
-t:hhmm
Specify this option together with -update.
Specify the reference time to be used to determine if the file was updated.
For example, for 13:35, specify -t:1335.
If this option is omitted, the current time or later is assumed.
-i interval
Specify the interval at which the status of the file will be checked, from 1 to 3600 seconds. If this option is omitted, the file status is checked at intervals of 1 second.
-a [Windows]
Use this option together with -fwait, -fupdate, or -fsize.
If the file status is checked, this command waits for access to the target file from other programs to cease. For example, if you specify -fwait to make the command wait for the file to be created and another program is creating (accessing) the file, the command does not terminate. If the file has been created when the status is checked after the next monitoring interval and other programs have ceased accessing the file, the command terminates.
-z
Checks the existence of the file. If the file does not exist, the command will terminate with return value 0. If you check the existence of the file without specifying this option and the file exists, the command will terminate with return value 0.
drive:file name [Windows]
Specify the full path name of the target file.
If none of the options -fwait, -fdelete, -fupdate, -fsize, -wait, -delete, or -update is set, specify the name of the file whose existence is to be checked.
You can specify the wildcard character "*" for all or part of the file name when you specify -fwait, -fdelete, -fupdate, or -fsize. Wildcard characters can be used only for the file name. They cannot be used to specify the drive name or directory name.
file name [UNIX]
Specify the full path name of the target file.
If none of the options -fwait, -fdelete, -fupdate, -fsize, -wait, -delete, or -update is set, specify the name of the file whose existence is to be checked.
You can specify the wildcard character "*" for all or part of the file name when you specify -fwait, -fdelete, -fupdate, or -fsize. But since the wildcard character "*" has a special meaning for the shell script, it must be escaped with a backslash (\). Wildcard characters can be used only for the file name. They cannot be used to specify the directory name.
-file:drive:list file name [Windows]
Use this option together with -wait, -delete, or -update.
Specify the name of a file (list file) that defines the target files.
If none of the options -wait, -delete, or -update is set, specify the name of the file that defines the files whose existence is to be checked.
You can list multiple file names in a list file.
You cannot specify wildcard characters in the list file name. Wildcard characters also cannot be specified in the file names defined in the list file.
-file:list file name [UNIX]
Use this option together with -wait, -delete, or -update.
Specify the name of a file (list file) that defines the target files.
If none of the options -wait, -delete, or -update is set, specify the name of the file that defines the files whose existence is to be checked.
You can list multiple file names in a list file.
You cannot specify wildcard characters in the list file name. Wildcard characters also cannot be specified in the file names defined in the list file.
-AND|OR
If a list file name is specified with the -file option, specify whether to target all files within the list file or to target a specific file.
If this option is omitted, the command targets all files within the list file. The following describes the behavior of the -wait, -delete, and -update options.
-wait option:
-AND | Waits for all files within the list file to be created. If all files already exist, a value is returned immediately. |
-OR | Waits for any one file within the list file to be created. If any file within the list file already exists, a value is returned immediately. |
-delete option:
-AND | Waits for all files within the list file to be deleted. If no files exist, the command will terminate abnormally with return value 1. |
-OR | Waits for any file within the list file to be deleted. If there are already no files, a value is returned immediately. |
-update option:
-AND | Waits for all files within the list file to be updated or created. |
-OR | Waits for any file within the list file to be updated or created. |
Return Values
Return value | Meaning |
---|---|
0 | The file was created/updated/deleted. Alternatively, the -z option was not specified and the file exists. Alternatively, the -z option was specified and the file does not exist. |
1 | The -z option was not specified and the file does not exist. Alternatively, the -z option was specified and the file exists. |
10 | An internal error occurred. |
Command Location
Windows | Systemwalker Operation Manager installation directory\MpWalker.JM\bin |
Solaris | /usr/bin |
Example 1
Example of waiting for a file with a name starting with "file" in the d:\temp directory to be created or deleted [Windows]
chkfile -fwait -fdelete d:\temp\file* |
Example of waiting for a file with a name starting with "file" in the /var/tmp directory to be created or deleted [UNIX]
jobschchkfile -fwait -fdelete /var/tmp/file\* |
Example 2
Example of waiting for all files (c:\a.txt, d:\b.txt, d:\c.txt) defined in d:\temp\list_file to be updated at or after 13:30 on December 5, 2014 [Windows]
chkfile -update -d:20141205 -t:1330 -file:d:\temp\list_file -AND |
[Example of d:\temp\list_file]
c:\a.txt |
Example of waiting for all files (/home/a.dat, /home/b.dat, /home/c.dat) defined in /var/tmp/list_file to be updated at or after 13:30 on December 5, 2014 [UNIX]
jobschchkfile -update -d:20141205 -t:1330 -file:/var/tmp/list_file -AND |
[Example of /var/tmp/list_file]
/home/a.dat |
Information
Registering commands as jobs
To automatically start job nets when a file is created/updated/deleted/resized, schedule the chkfile and jobschchkfile commands as jobs. By registering a command as the first job in a job net, you can make later processes wait for a file to be created/updated/deleted/resized.
Execution Result/Output Format
Output example of chkfile [Windows]
CF_FILENAME=d:\temp\file1130 |
Output example of jobschchkfile [UNIX]
CF_FILENAME=/var/tmp/file1130 |
Cautions
If you register this command with the -fwait, -fdelete, -fupdate, -fsize, -wait, -delete, or -update option as a job with Jobscheduler, the command continues executing until the desired file is created/updated/deleted/resized. In the submission queue, check the limitations on the job elapsed time and the number of jobs that can be executed simultaneously, and change the settings for the queue if there is an issue.
You can use the -a option with this command to wait until access to a file is complete. However, it cannot be guaranteed that file transfer will be completed with transfer programs that temporarily cease access during file transfer. In this type of situation, send a small file reporting transfer completion after the target file has been sent. Then wait for the update of this file to confirm that the target file has finished transferring. [Windows]
This command checks the status of files at the monitoring interval specified by the -i option. It detects changes in the file by comparing its state when it is monitored one time to the next. Changes will not be detected properly if files are created, deleted, updated, or resized at intervals shorter than the monitoring interval. If a file is created and then immediately deleted in the interval between one monitoring and the next, neither the creation nor the deletion of the file can be detected.
If changes in multiple files are detected within one monitoring interval, the information on the file detected first will be output.
Specify one file name per line in the list file. A file name cannot include spaces or tabs.
On Solaris, HP-UX, AIX, and Linux x86, ensure that the target file does not exceed 2 GB.