Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Purging/Trimming script in Ubuntu 10.10 not working?
New Posts  All Forums:Forum Nav:

Purging/Trimming script in Ubuntu 10.10 not working? - Page 4

post #31 of 45
Quote:
Originally Posted by Plan9 View Post


Good point.
Nope, the script appears to be correct.
I'm starting to wonder if Ubuntu properly supports -mmin as I have heard of cases where it's incompatible with *nix systems (though I'd be amazed if GNU find hasn't since implemented it).
However he could try relacing -mmin 720 with -mtime 1 -mtime +1


ubuntu will recognize the -mmin +720.

 

if he put the cp -rp like you suggested earlier into the script (which it appears to be from a previous post of his), then he is preserving the timestamp as well, so the modification date will not change, i'm sure if he drops the cp -rp and goes back to cp -r like he originally had it, it should now work.

 

and btw, chmod 755 , does not alter the modification date of the file(s).


Edited by Transhour - 12/9/11 at 5:48am
Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
post #32 of 45
Thread Starter 
Code:
user="stuart" 
now=$(date +"%Y-%m-%d_%T") 
cd ~ 
cp -r "/home/$user/fah" "/home/$user/backup/$now" 
find /home/$user/backup* -mmin +720 -exec rm -rvf {} \\;

With the latest suggestion, here is what I have as backup.sh

I'm going to have to let it run for 12 hours before I know if it is working because I tried another suggestion before plan9 said it wouldn't work and lost my backup folder again... haha.
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
post #33 of 45

change the \\; on the last line, to \;

Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
post #34 of 45
Quote:
Originally Posted by Transhour View Post


ubuntu will recognize the -mmin +720.
By Ubuntu, it's more a GNU thing, but yes, I thought it would. There did used to be issues a while back (5 or 6 years ago), but I was pretty sure it had been implemented since then.
Quote:
Originally Posted by Transhour View Post

if he put the cp -rp like you suggested earlier into the script (which it appears to be from a previous post of his), then he is preserving the timestamp as well, so the modification date will not change, i'm sure if he drops the cp -rp and goes back to cp -r like he originally had it, it should now work.

Good point. I guess we've proven it's not permission related now (back when he had other issues with the script it wasn't clear what permissions the files were being duplicated with) so there's no need to preserve smile.gif

Though he could arguably use amin if he wanted to keep the preserve - but that would obviously have other side effects. So removing the preserve flag would make sense.

Of course, the other option (and the way I would have built the script) would be to purge based on folder name (which is/would be time stamped). That's a whole other script though:)
Edited by Plan9 - 12/9/11 at 5:56am
post #35 of 45
Quote:
Originally Posted by stu. View Post

Code:
user="stuart" 
now=$(date +"%Y-%m-%d_%T") 
cd ~ 
cp -r "/home/$user/fah" "/home/$user/backup/$now" 
find /home/$user/backup* -mmin +720 -exec rm -rvf {} \\;
With the latest suggestion, here is what I have as backup.sh
I'm going to have to let it run for 12 hours before I know if it is working because I tried another suggestion before plan9 said it wouldn't work and lost my backup folder again... haha.

You don't need the v in your exec rm command any more. (I don't know if ubuntu has sendmail installed, but if it does, keeping -v will fill your inbox up)
post #36 of 45
Thread Starter 
Quote:
Originally Posted by Transhour View Post

change the \\; on the last line, to \;

When the command is run with only one \ in terminal, the entire backup folder is deleted though?
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
post #37 of 45
Quote:
Originally Posted by stu. View Post


When the command is run with only one \ in terminal, the entire backup folder is deleted though?


well yes and no. 

 

The problem has always been the \\; being there, instead of \;, so when you ran the script manually with the change, it deleted like it was designed too, the problem with it deleting everything was the, cp -rp that was added. (ironically enough, if you had switched to the tar script I had posted, it would've fixed itself, cause I had the \; in there lol).

 

when you added the -p to the cp command, you were essentially telling it to do a carbon copy backup, where it would preserve not only each files permissions, but also their timestamps (including the modification time), which -mmtime uses to determine "how old" a file is. So when the command got fixed, with everything using cp -rp to back at that time, they all had "modification" times older than 12 hours. 

 

with cp -rp being replaced again with cp -r, and the \\; replaced with \;, it should now work as intended.

Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
post #38 of 45
Thread Starter 
I don't know what I did now...
I ran the backup.sh script earlier (8:50am) with one of the modifications suggested, which deleted the entire backup folder, INCLUDING the actual folder itself. I remade the folder and reverted backup.sh.

However, I just checked and there are NO backups in the backup folder. I tried running the script in the terminal and got this:

Code:
stuart@foldingbox1:~$ cd ~
stuart@foldingbox1:~$ ./backup.sh
bash: ./backup.sh: Permission denied
stuart@foldingbox1:~$

confused.gif

Edit: I forgot to set permission for backup.sh, whoops (chmod 755 backup.sh)
Code:
user="stuart" 
now=$(date +"%Y-%m-%d_%T") 
cd ~ 
cp -r "/home/$user/fah" "/home/$user/backup/$now" 
find /home/$user/backup* -mmin +720 -exec rm -rf {} \;

We have confirmation that a backup folder has been made! In 12 hours we'll know if the script is full functioning! wheee.gif
Edited by stu. - 12/9/11 at 7:13am
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
 
F@H
(14 items)
 
 
CPUMotherboardGraphicsRAM
Core i7 920 @ 4.0ghz EVGA x58 132-BL-E758-A1 2x EVGA 460 1 GB G.SKILL 3 x 2 GB 
Hard DriveOSMonitorKeyboard
Mushkin 40 GB SSD / WD Black 1 TB Windows 7 Home Premium 64-bit DCLCD 20.1" Logitech G15 
PowerCaseMouse
Antec TP 750 Antec 900 Logitech G5 
CPUMotherboardRAMCooling
i7 2700k ASUS Maximus Gene-Z z68 G.Skill 2133mhz Noctua NH-D14 
OSPowerCase
Ubuntu 10.10 BFG 650 Silverstone TJ08-E 
  hide details  
Reply
post #39 of 45
Quote:
Originally Posted by stu. View Post

I don't know what I did now...
I ran the backup.sh script earlier (8:50am) with one of the modifications suggested, which deleted the entire backup folder, INCLUDING the actual folder itself. I remade the folder and reverted backup.sh.
However, I just checked and there are NO backups in the backup folder. I tried running the script in the terminal and got this:

Code:
stuart@foldingbox1:~$ cd ~
stuart@foldingbox1:~$ ./backup.sh
bash: ./backup.sh: Permission denied
stuart@foldingbox1:~$
confused.gif
Edit: I forgot to set permission for backup.sh, whoops (chmod 755 backup.sh)
Code:
user="stuart" 
now=$(date +"%Y-%m-%d_%T") 
cd ~ 
cp -r "/home/$user/fah" "/home/$user/backup/$now" 
find /home/$user/backup* -mmin +720 -exec rm -rf {} \;
We have confirmation that a backup folder has been made! In 12 hours we'll know if the script is full functioning! wheee.gif


I feared that would happen, might want to change rm -rf back to rm -r, as rm -rf will more than likely delete backup folder lol.

 

Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
Bazinga Punk
(12 items)
 
ooh shiny!
(6 items)
 
 
CPUMotherboardGraphicsRAM
Intel Xeon 3440 AsRock P55 extreme Evga 8800 GT 512 MB Gskill Ripjaws 
Hard DriveCoolingOSMonitor
Western Digital Blue Antec Khuler 620 Ubuntu 11.10 Asus vw264H 
KeyboardPowerCaseMouse
GIGABYTE KM7600 CORSAIR TX 650 Cooler Master 590 GIGABYTE GM-M6800 
CPUMotherboardGraphicsRAM
Intel Core I5 6500 Gigabyte z170xp-SLI Nvidia 970gtx Corsair 16gb ddr4 2666mhz  
Hard DriveOS
250gb Samsung Evo 850 Windows 10 & Ubuntu 15.10 
  hide details  
Reply
post #40 of 45
Quote:
Originally Posted by Transhour View Post



I feared that would happen, might want to change rm -rf back to rm -r, as rm -rf will more than likely delete backup folder lol.

to be fair, that wouldn't have happened with with -f if the find path was formatted correctly:
find /home/$user/backup* should have been find /home/$user/backup/
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › Purging/Trimming script in Ubuntu 10.10 not working?