PuppyThis forum is for the discussion of Puppy Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Based on date is a bit ambiguous. You can find lots of examples of using the find command to copy files based on date. By using cron you can copy the files once a day at a certain time.
One idea would be to create a file using the touch command after the script copies the files that uses the date as the name. Then add a if then that checks if that file exists before the copy.
I really do not understand. If you have a script that copies files then only run it once a day. Since I don't know how the script actually works I just threw out an idea.
Code:
today=$( date +%F )
if [ ! -f "$today.txt" ]
then
copy files
touch $today.txt
fi
It will create a dummy file each day. Its up to you to delete them etc.
Yes, if you delete file on the same day then it will execute the script again.
The code I posted will compare the current date with the filename. If the file does not exist then your script should copy the files. Adding time to the filename will overly complicate the script and from what you posted is not required.
You can add another if statement like the following after the files are copied.
Code:
yesterday=$( date --date="-1 day" +%F )
if [ -f "yesterday"]
then
rm $yesterday.txt
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.