LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2017, 08:24 AM   #1
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Rep: Reputation: Disabled
Compress folders every 6 months


I generate a folder everyday consisting of different reports. I would like to compress these folders(named 0101207,01022017,etc etc) every six months. So folders named 01012017 to 06312017 would be compressed to a folder named 'Jan2017_Jun2017'. Then of course folders starting on 07012017 to 12312017 would be compressed in a folder named 'July2017_Dec2017. These folders are on a Windows shared folder. It would be ok for this automated tasks to be installed and ran from my laptop, but if it can be ran via CRON job that would be ok too, whichever is easier. Is this possible? Any help is highly appreciated
 
Old 01-11-2017, 08:29 AM   #2
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Code:
sudo crontab -e
was my first thought...
 
1 members found this post helpful.
Old 01-11-2017, 08:43 AM   #3
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
I'm not allowed to use this program, and it takes too long and I have to go through too much to get permission to run certain commands. I guess it would be better for it to run from my laptop.
 
Old 01-11-2017, 08:48 AM   #4
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Is it Linux on your laptop because that's how to setup a CRON job (IMHO the easy way...)
 
1 members found this post helpful.
Old 01-11-2017, 09:38 AM   #5
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
No, unfortunately it's Windoze(YUCK).
 
Old 01-11-2017, 09:49 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,914
Blog Entries: 13

Rep: Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948
@trickydba, unfortunately this is not a Windows forum.

Is Linux involved here at any point? You cited cron and then you said you can't use it due to Windows.

If you wish automated tools for Windows, then please seek an alternate forum on LQ such as the Non-Nix-General forum, or give Stack Overflow a try.

As far as Linux goes, people can offer some suggestions; however you need to cite your topology of systems, tell us where Linux is being used, or is capable of being installed, or allowed to be installed, and then people can offer some solutions here.
 
1 members found this post helpful.
Old 01-11-2017, 01:15 PM   #7
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
Well I just recently found out since creating this thread that I cannot create a cron job. I apologize. I guess at this point I would like to have a script that I can execute MANUALLY that can resolve my issue
 
Old 01-11-2017, 01:20 PM   #8
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Isn't this a political issue rather than a technical one?
If you're employed as a DBA and expected to back up then you need cron -- if your employer says otherwise get it in writing they don't want a backup and forget about it (whilst looking for a new job in case the imbeciles take the company down).
 
1 members found this post helpful.
Old 01-11-2017, 02:08 PM   #9
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
Well the work I do is dba plus more but I just chose to have it a part of my user name just because it was the 1st thing that came to my mind
 
Old 01-11-2017, 02:10 PM   #10
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by trickydba View Post
Well the work I do is dba plus more but I just chose to have it a part of my user name just because it was the 1st thing that came to my mind
Regardless of your job title: if your employer prohibits you from doing you job then document it and move on.
 
1 members found this post helpful.
Old 01-11-2017, 02:23 PM   #11
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
I understand.........still at this time I humbly ask for assistance with my issue. Is it possible in a script I can run every 6 months manually? I figure I can get the script 1st then request for the access to create a cron task. Either way, I would still need help

Last edited by trickydba; 01-11-2017 at 02:25 PM.
 
Old 01-11-2017, 03:01 PM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,326

Rep: Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919Reputation: 919
Quote:
Originally Posted by trickydba View Post
I generate a folder everyday consisting of different reports. I would like to compress these folders(named 0101207,01022017,etc etc) every six months. So folders named 01012017 to 06312017 would be compressed to a folder named 'Jan2017_Jun2017'. Then of course folders starting on 07012017 to 12312017 would be compressed in a folder named 'July2017_Dec2017. These folders are on a Windows shared folder. It would be ok for this automated tasks to be installed and ran from my laptop, but if it can be ran via CRON job that would be ok too, whichever is easier. Is this possible? Any help is highly appreciated
mite i suggest using better file names so that they sort better. something like year--month--date or year--day-of-year.

the script would probably call for things like tar:
Code:
tar -cvjf 2017.5.tar.bz2 /path/to/files
what have you tried so far ?

Last edited by schneidz; 01-11-2017 at 03:23 PM.
 
1 members found this post helpful.
Old 01-11-2017, 03:46 PM   #13
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
I was thinking this might work, from an older thread:
Code:
 
 find . -name '*.DAT' -mtime -182 | xargs  tar -czvf  Jan2017Jun2017.tar.gz
I don't know if this is right but I wish it to be more dynamic in that maybe a requester pops up asking whether the save is for Jan to Jun or July to Dec. I came up with this code so far using Whiptail:
Code:
#!/bin/bash
OPTION=$(whiptail --title "Folder Compressor - By Me" --menu "Choose your date range to compress" 15 60 4 \
"1" "January to June" \
"2" "July to December"  3>&1 1>&2 2>&3)

exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your chosen option:" $OPTION
else
    echo "You chose Cancel."
fi
Now I would like for it to operate like this:
If I choose number 1, it will run my code(if it's right) and create the compressed filename 'JanJun2017', appending the year
If I choose number 2, it will run my code and create a compressed file 'JulyDecember2017' appending the year
showing a progress bar, then when done it shows "Compression successful!" and exits.

I know Whiptail has a 'gauge' function that displays a progress bar

Last edited by trickydba; 01-12-2017 at 01:17 PM.
 
Old 01-11-2017, 05:33 PM   #14
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,914
Blog Entries: 13

Rep: Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948Reputation: 4948
What you just wrote is what I was going to suggest. To use find and tar.

I do not feel you need to use a script.
 
1 members found this post helpful.
Old 01-11-2017, 05:54 PM   #15
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,176

Rep: Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644Reputation: 3644
Notes.

I know this isn't the question asked but if I wanted to store data on a windows machine then I'd use windows folder compression tools to save data and make the information seamlessly available to all resources.

However many linux programs might be ran from limited user permissions. Tar and many other programs could be used and piped to some compression and some have switches that make renaming rather easy. Kind of the issue is how much permissions do you have in linux. Simple tar may not be allowed. You could even have some higher permissions that allow distro based programs to be run.

Last edited by jefro; 01-11-2017 at 05:57 PM.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate compress files after 7 days and keep them for two months. mariogarcia Ubuntu 4 12-13-2013 09:29 AM
Shell Script to compare folders,Sub-Folders and Sub-Sub-Folders unix_72427 Programming 8 08-08-2012 03:51 PM
Loop mounting compressed folders: which ones are safe to compress? mahkoe Linux - General 1 12-13-2011 04:13 PM
bash script to create folders including making recursive folders.... linux-bandit Linux - Software 8 11-28-2009 02:50 AM
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 05:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration