I have different directories on supercomputer and the issue is that all files will be deleted after a short time with no touch. Is there any command, library or function in R or bash (Preferably in R) to loop over all directories and keep files alive? (I don't want to update files) Thanks in advance
In your case, you have certain files which will be deleted if they are not modified within a set interval. You can just touch
the files to prevent them being deleted. But that said, you need to add a cron
job to automate the touching process. It can be as simple as
#!/bin/bash
#This script is named say touchscript.sh
#Your list of directories to deal with go below
dirlst=("/path/to/dir1" "/path/to/dir2")
for dirvalue in "${dirlist[@]}"
do
find "$dirvalue" -type f -exec touch {} \;
done
And add a cronjob
0 * * * * /path/to/touchscript.sh
Note: touchscript.sh
should be an executable ie do chmod u+x
to that. Use crontab -e
to add a cronjob and put the above in there