You are not logged in.
Pages: 1
In Bash, how to get a file deleted not less than 1 hour?
last-exit-time=`cat /test/time.txt`
if [ $current-time above-1h $last-exit-time ]; then
rm -f /test/file.tmp
fi
Markku
Offline
-gt greater than
-lt less than
-eq equal to
-ge greater than or equal to
-le less than or equal to
assuming you have $current-time already defined:
if [ $current-time -gt $last-exit-time ]; then
rm -f /test/file.tmp
fi
Offline
How about using the at daemon?
something like this (not sure of the exact syntax):
at now+1h rm -f /test/file.tmp
If its a repetitive job, of course you would use cron.
Dusty
Offline
If its a repetitive job, of course you would use cron.
This is for the PacTK, which is not that great as pacman.:) Instead of downloading each time the latest package list from ArchWD repo, when installing a package, the script will do it only once. If the user installes after one hour or just want to see what's available, then the list will be downloaded again.
Thanks Penguin, got it working.
TMP="$HOME/.fvwm/archwd-user/tmp"
date +%s -d "1 hour" > $TMP/latestlist.tmp
if [ -f $TMP/latestlist.tmp ]; then
Last=`cat $TMP/latestlist.tmp`
date +%s > $TMP/now.tmp
Now=`cat $TMP/now.tmp`
if [ "$Now" -gt "$Last" ]; then
rm -f $TMP/latestlist.tmp
rm -f $TMP/now.tmp
fi
fi
Markku
Offline
Pages: 1