Page 1 of 1

Bash script to delete then move ALL files.

PostPosted: Wed Mar 16, 2016 1:54 pm
by badams_ios
I know absolutely NOTHING about scripting. I'm running Linux Mint 17.3

I need a new bash script that will run as a cron job.

Then, let's say I have 2 folders we'll call A and a sub-folder, B. On a day specified by cron, I want to delete all files from B. No errors if none exist, just keep going to step 2. Step 2 should MOVE all files from A to B. No errors if nothing exists in A.

Here's my scenario. On the 1st Monday of each month at 6:00 am, a full backup is made to a shared folder. On the 2nd, 3rd and 4th week, it'll make a differential backup to the same location. Those I already have working. THANKS to the support team here! Then on the 1st Monday, at 2:00 am it deletes all the files in B and moves all of A to B.

I'd like to ADD to the scripts that make the backups, a warning that the system is going to reboot and give me 5 minutes to save any work. Just a simple eye catching box in the middle of the screen that says "GOING DOWN!" It doesn't need to say "In 5 minutes" and it doesn't need to give a count down. (Unless you feel like it :lol: It'd be nice if I could minimize that message, but no big deal if I can't.

Re: Bash script to delete then move ALL files.

PostPosted: Thu Mar 17, 2016 7:27 pm
by TeraByte Support(PP)
I've attached a zip file with several short scripts you should be able to tweak/schedule how you want. One will delete and move files and two will show a notification message (different programs). I would recommend testing with files that don't matter first before using on your backups -- don't want to lose them while getting things configured.

Re: Bash script to delete then move ALL files.

PostPosted: Sat Mar 19, 2016 5:19 pm
by badams_ios
Thanks, I'll give 'em a try soon.