Switch to full style
User discussion and information resource forum for scripting of TeraByte products using script lanugages such as TBScript, VBScript, Batch Files, and more.
Forum rules
Post a reply

Bash script to delete then move ALL files.

Wed Mar 16, 2016 1:54 pm

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.

Thu Mar 17, 2016 7:27 pm

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.
(814 Bytes) Downloaded 523 times

Re: Bash script to delete then move ALL files.

Sat Mar 19, 2016 5:19 pm

Thanks, I'll give 'em a try soon.
Post a reply