Debian Shell Bash Script - Delete old backups/directorys [closed] - bash

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a small script which is creating a backup every 2 hours. Now I would like to delete the old ones. I know "find" can do this, but I want it more advanced.
I want to keep
all backups form the last 24 hours
4 backups from the last 5 days
1 backup from the last 14 days
everything older than 14 days can be deleted
Could you tell me how to do this via. a shell bash script in debian ?
I couldn´t find anything for this via. google.
Thank You.

Do not reinvent the wheel. Take a look at rsnapshot. Unless you want to use this as a learning exercise, I see no reason why you would want to spend the time that has already been spent to solve this problem.

Related

How to parallelize a UNIX for-loop? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I apologize for the somewhat simple question (I am new to UNIX programming). I am using an HPC system and would like to parallelize a task in a for loop (in this case, a simple unzip to be applied to several files).
How could I do this? I thought that by requesting multiple cores the parallelization would start automatically, but actually the program is operating sequentially.
Thank you very much!
for i in *.zip; do unzip "$i" -d "${i%%.zip}"; done
In bash it would look something like:
for item in bunch-of-items; do
(
the loop body
is here
) &
done
Where the parentheses group the commands, and the whole loop body is put in the background.
If the rest of your program needs all the background jobs to complete, use the wait command.

Windows 8 cli to take screenshots [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm using boxcutter and take screenshots via command line. I want a loop that runs for 4 hours and takes screenshots every 10 seconds. I CAN NOT get a .bat to do this. First, I can't figure out how to make the script sleep for 10 seconds. Below is my code and no matter what variation I try my prompt just flashes quickly and is gone, yes I have used some choice words on this gem.
ECHO ON
for /l %i in (1,1,10) do
E:\boxcutter\boxcutter.exe -f E:\screenshots\%i.png
ping -n 10 someserver.com
done
pause
Any help is appreciated.
Try this instead:
for /l %%i in (1,1,1440) do (
E:\boxcutter\boxcutter.exe -f E:\screenshots\%%i.png
ping -n 10 localhost>nul
)
pause
This will take screenshots 10 seconds apart for 1440 iterations (which is 4 hours). Note that I doubled the percent signs in the for loop since this is running in a batch file, and I corrected the syntax for for...do...
You'll find it much easier to troubleshoot batch files if you open a command prompt and run them from there rather than double-clicking them from Windows Explorer. The command prompt will stay open rather than flashing briefly and disappearing.

How to get more than 40 windows in GNU screen under Debian [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using the terminal program called screen, which can create several "virtual terminals" in a single "real" terminal (the words "virtual" and "real" here are quite relative, the "real" terminal can be a konsole tab as well, not necessarily tty1-tty6). The problem is that I cannot create more than 40 windows inside a single screen. When I try to create more, screen says "No more windows." After some googling I found that that this is controlled by something called MAXWIN, but I didn't find any information how to modify this MAXWIN. How can I increase the maximal number of windows inside a single screen?
I use Debian 6 "squeeze".
PS I understand that I can run several screen's in several "real" (in the above sense) terminals, but this makes it harder to use multiple display mode (screen -x).
That's a compile time option. Using strictly packages from upstream, it can't be done. If you wanted to compile screen yourself, you could accomplish this. Look in the config.h.in file. Near the top will be # define MAXWIN 40. Change that to your new limit.
(more info)

How to repeat last command parameter in ZSH [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I often need to move file from one location to other, but it requires copying and pasting huge part of the command. For example:
mv ~/Projects/foo/bar/baz.img ~/Projects/foo/bar/fiz.dmg
Is it possible after entering ~/Projects/foo/bar/baz.iso part of above command to use some shortcut that duplicates it so I can change the very end to fiz.dmg?
You don’t need this:
mv ~/Projects/foo/bar/baz.img ~/Projects/foo/bar/fiz.dmg
easily turns into
mv ~/Projects/foo/bar/{baz,fiz}.img
. Note: zsh completion is still available when you write { (unless you have a habit of writing closing } right away) if you want it.
I actually discovered one possible solution. Just press:
Ctrl+W few times and then Ctrl+Y two times (and space between pastes).

Vim slow performance when dealing with remote files [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm opening a file on a remote drive - it takes 3-4 seconds to open it - that's ok.
But afterwards, a lot of commands become really slow.
I'm typing :help vimrc - it takes 3-4 seconds to display.
I'm typing :setlocal nobuflisted - it takes 3-4 seconds.
It probably has something to to with those commands accesing the filesystem. If I do :setlocal list it works ok.
Also if I switch to another buffer, everthing is back to normal again.
Is there something I can do to improve performance?
Maybe the swap file is created in the remote directory and slows down your performance.
Try setting the default directory for swap and backup files on your local drive with:
set directory=/home/john/tmp
set backupdir=/home/john/tmp
Check your 'statusline' setting and autocmds on events like CursorMoved[I] and BufWinEnter.
I once had a function in my status line that invoked expand('%:p:h'); it caused a noticeable slowness as experienced by you. I fixed this by caching the lookups in a script-local Dictionary.

Resources