2015-02-05 8 views

Antwort

11

Ich denke, das wäre hilfreich,

find . -mmin -2 -type f -print 

auch,

find/-fstype local -mmin -2 
4

ich das Problem auf diese Weise gelöst: das aktuelle Datum und Datum der letzten Änderung der Datei (beide in Unix-Zeitstempel Format). Ziehen Sie das Änderungsdatum vom aktuellen Datum ab und teilen Sie das Ergebnis durch 60 (um es in Minuten umzurechnen).

expr $(expr $(date +%s) - $(stat mail1.txt -c %Y))/60 

Vielleicht ist dies nicht die sauberste Lösung, aber es funktioniert gut.

6

komplette Skript zu tun, was Sie nach:

#!/bin/sh 

# Input file 
FILE=/tmp/test.txt 
# How many seconds before file is deemed "older" 
OLDTIME=120 
# Get current and file times 
CURTIME=$(date +%s) 
FILETIME=$(stat $FILE -c %Y) 
TIMEDIFF=$(expr $CURTIME - $FILETIME) 

# Check if file older 
if [ $TIMEDIFF -gt $OLDTIME ]; then 
    echo "File is older, do stuff here" 
fi 
Verwandte Themen