大型机服务器find命令-cmin/-mmin选项报错FSUM6372求解决方案
-cmin/-mmin) Got it, let's work through this problem since your mainframe's find utility doesn't support the -cmin/-mmin options you're used to. Here are a couple of practical, mainframe-friendly solutions to locate files matching your naming pattern ([0-9]{5}_[A-Z]{2}.dat) that were modified in the last 10 minutes:
Option 1: Use a Shell Script with Timestamp Calculation
This approach uses basic shell commands to calculate time differences between the current time and each file's modification time. It's great if you're dealing with a manageable number of files:
#!/bin/ksh # Calculate current time in total minutes since epoch current_min=$(date +%s | awk '{print int($1/60)}') # Loop through all files matching your naming pattern for file in /input/[0-9][0-9][0-9][0-9][0-9]_[A-Z][A-Z].dat do # Skip if the file doesn't exist (in case no matches are found) [[ ! -f "$file" ]] && continue # Get the file's modification time in total minutes since epoch # Adjust the ls command based on your mainframe's ls output format if needed file_mod_time=$(ls -l --time-style=+%s "$file" | awk '{print $6}') file_min=$(awk -v t="$file_mod_time" '{print int(t/60)}') # Check if the file was modified within the last 10 minutes if (( current_min - file_min <= 10 )); then echo "Found recently modified file: $file" fi done
Note: If your mainframe's ls doesn't support --time-style=+%s, you may need to parse the human-readable timestamp (e.g., MM/DD/YYYY HH:MM) using awk or sed to convert it to total minutes.
Option 2: Use find with -newer and a Temporary File
This method leverages find's -newer option (which most mainframe find implementations support) by creating a temporary file with a modification time set to 10 minutes ago. Files newer than this temp file are your target:
#!/bin/ksh # Create a temporary file with modification time set to 10 minutes ago # Adjust the date format if your mainframe's date/touch tools use different syntax touch -d "-10 minutes" /tmp/10min_placeholder.tmp # Use find to locate files matching your pattern that are newer than the temp file find /input -name "[0-9][0-9][0-9][0-9][0-9]_[A-Z][A-Z].dat" -newer /tmp/10min_placeholder.tmp # Clean up the temporary file rm /tmp/10min_placeholder.tmp
If your mainframe's touch doesn't support the -d flag, you can calculate the exact timestamp manually and use touch -t:
# Calculate 10 minutes ago in YYYYMMDDHHMM.SS format ten_min_ago=$(date -d "-10 minutes" +"%Y%m%d%H%M.%S") touch -t "$ten_min_ago" /tmp/10min_placeholder.tmp
Both options should work on most mainframe Unix-like environments (like z/OS USS). Test them with a small set of files first to ensure compatibility with your system's command syntax!
内容的提问来源于stack exchange,提问作者user13021483

