Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Hi guys I use centOS 64bit 5.7 and I need to create a backup script

What I want it to do:

  • screen -r example
  • command into java
  • pause for x amount of seconds
  • exit screen
  • zip/rar a folder which and put a timestamp on the name (with date) and move it to a different location
  • pause for duration of the zipping? If not a predetermined time.
  • screen -S example java -Xmx3g -Xincgc -jar server.jar nogui

Any ideas?

share|improve this question
Think about some simpler approach. Can you adjust your java to do command in say 1am, and run your script at 2am? – rvs Dec 23 '11 at 12:50
4  
It is very unclear what you are trying to do. Why and how do you want to use screen? What role does java play? Why the pauses? What are you trying to backup? – rozcietrzewiacz Dec 23 '11 at 12:51
I'm trying to backup my minecraft folder. I want to go in the screen which gets created and execute a few things in it. The pauses are for when a command is sent e.g. 5 seconds to pause1 1; 4 seconds to go. Need a screen running for the load the program – Josip Gòdly Zirdum Dec 23 '11 at 13:21

closed as too localized by Chris Down, Michael Mrozek Dec 26 '11 at 4:16

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Did it myself. Thanks anyway guys.

STAMP=`date +%d-%m-%Y_%H%M%S`

screen -x example -X stuff "`printf "command"`"
pause 10;
screen -x example -X stuff `printf "commandr"`
pause 10;
kill `pidof example`
tar -cvzf /directory/of/folder/I/want/backups/to/go/$STAMP-backup.tar.gz /directory/of/folder/I/want/backed/up/
screen -S example java -Xmx3g -Xincgc -jar server.jar nogui
screen -x example -X stuff `printf "save-on\r"`
screen -x example -X stuff `printf "save-all\r"
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.