Programming :: Create A Shell Script That Would Automatically Backup And Shutdown?
Oct 14, 2010
I would like to develop a shell script that would automatically run a backup program and then shutdown the computers, but I do not know the first thing about script development or even writing scripting.
I have a shell script that need to create some files:
1) backup files of user passed in file ( that will be written by this shell ).
2) temp files that the shell will create and later delete/remove.
This shell script will be used from my local dir ( I am not a super or a sysadmin ). Users of this shell will call this script to run on their local files in their respective directories. When my script runs, it errors with the following:
for the temp I was able to avoid this error by creating the temp file in the /tmp directory. All I want is for this shell script to run, create/modify/backup files in user's local dirs.
i have a RAMdisk set up on my desktop with a hidden folder of stuff in it; but i want to know is it possible for me to set ubuntu to copy the files to another directory on shutdown, and copy back again on startup?
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code: if [ $# -eq 0 ] ; then d=`pwd` for i in * ; do if test -d $d/$i ; then echo "$i:" code....
I was trying to create a shell script which will automatically login to the server 192.168.1.7 and checks if a user exists there or not, if it doesn't exist then it should create the user.I have very little idea about shell scriptThis is what I tried:Quote:
#!/bin/bash pass="sacharje" ssh 192.168.1.7
Now, how to pass that password automatically to the ssh when it asks for the password? (I can't use public key authentication here)
I have installed Oracle 11g on 5.3. Now, I am trying to START and STOP oracle automatically on system startup and shutdown. I am following this link To have this effect, I have created /etc/init.d/dbora
I have requirement on shell scriptingre scripts for the following: 1) Full backup(application and DB): tar all the files and database and copy them in the backup server 2) Incremental back up of files: backup of all the updated filester the last backup. 3) Restoring of backup files: restore the backup files from the backup server to the application server.
I want a script to get executedutomatically whenever I login.Code is simple:Quote:dateYEs! it prints the date on the screen.I read somewhere that there is login.sh shell script which get executed automatically whenever one opens console.But how to insert the above code into it.?Also, we can put our command in $HOME/.bashrc and it will get executed everytime I start the interactive shell.
The two shell scripts (t1prog and t2prog) are given below they are working fine. The input for the first program is 't1.det' and for second program is 't1.rnaml'. These two input files are in 'dir1' folder. I am executing the shell like 'sh t1prog > t1out' and 'sh t2prog > t2out' from this directory only. Then I am executing a java program 'java RNA'; for this, t1out and t2out are input files used in the program and I am getting the final output on screen.
The input files 't1.det' and 't1.rnaml' are in different folders with same name and with different values. Each folder specifies one gene sequence input files.
In mfold directory there are 5 directors and each directory contains these input files as shown below cd mfold dir1 dir2 dir3 dir4 dir5 cd dir1 t1.det t1.rnaml
[Code].....
for inputs in different directories and executing these and redirecting the final ouput after executing 'java RNA' statement to a file is needed.
I take responsibility for data backup my centos server. Please help me backup data using tar. following scenario:- Sunday - full backup- the rest of differential backup.We're back up to full as follows:tar-cvzf / backup / backup-date.tar.gz / data
I am facing a problem in Windows due to a virus called Newfolder.exe which creats files with the same name as it's parent directory and an extension .exe and this happens for every directory in the entire hierarchy in the infected pen drive. The antivirus detects them, but is sucking slow. So I thought this is a good opportunity to use the concepts of the all mighty shell script to remove those as they follow the same pattern. Say my complete path is
Code:
/home/pkd/fol1/
The virus would have created an file with complete paths
Quote:
/home/pkd/fol1.exe
If fol1 has two more directories fol11 and fol12 Then there would be two more .exe(virus created) in the following path
How do I create a user account in a shell script? I know this may sound n00bish to you, but I know it's more than just mkdir-ing the home directory and subdirectories.
I came across this script a while back that i found. What i want to do is edit the script to create a default web page in /var/www/html a new user is added through the script.What the script does now is adds a user and sets a password for the user. What possible way (either through a combination of python or c or some other language) could i add to the shell script to do this? I've tried just dointhe command to touch index.html /var/www/html but it puts it on the desktop. Here's the script....
Code: #!/bin/bash # Script to add a user to Linux system
I would like to create a bash menu script for my home server For instance if i were to type ./script It would then bring up 3 options
a. Create a backup b. Restore files from a backup c. Quit
If you were to select a or b it should then ask you were you want to backup or restore from. And if i were to type in an incorrect letter i should get an error and take me back to menu. I have attepmted this a view time now and have magaged to get the menu up using parameters
I create Backup partition with dd and save my backup on NTFS partition. i want recover this backup,what should i do? can i use boot cd and use dd command for recover it?
I've been googling my brains out looking for a solution to this. So far, nothing.
As the title suggests, every time I attempt to shut the computer down it instantly reboots the moment the internal fans stop whirring.
So far I've tried:
-shutting down via the terminal (this actually makes the reboot happen instantly rather than waiting for the fans to stop)
-looking in the BIOS for any obvious settings which may be causing this
-performing a dpkg repair
-Allowing "Proposed" updates in the Updater
-installing (slightly) older Kernel (2.6.35-22 as opposed to 2.6.35-23)
-installing newer (2.6.36) kernel
I know others are having this issue, but other threads I've read seem to have fizzled out with no conclusion. Has anyone managed to find a way to make this work if they've had the bug?
Any advice at all? Is it worth trying an even older kernel? Or an even older version of Linux?
I got a question, is there a script or program that automaticly boots my server and shutdown at give hours of a day I want to have my server running from 7am till 8pm ever weekday (Monday-Tuesday-Wednesday-Thursday-Friday) is this possible? I'm running a Ubuntu 10.04 server with Zentyal on
My RHEL Machine is a Build server and always gets shutdown / rebooted at around 5:30 every evening. No idea whats going on as developers were unable to connect to the machine since three days. When I am visiting the physical server probably next morning (since last 3 days)its doesn't show anything and all i reboot the machine and it comes up without any issue. how to troubleshoot?
I'm looking for a program or script that will automatically shut down my computer at specified times. The thing is, if I happen to be using the computer at those times, I want it to ask me if I want to shut down before it does it.
Something like I want the computer to shut down at 9 am every day. When it's 9am, a prompt pops up and says, "Do you want to shut down or continue running? If you do not answer, the computer will automatically shut down in 10 seconds." Not sure if something like this is out there or not.
It seems to me that the /tmp folder is currently crowded with old stuff. How can I tell CentOS to always automatically delete all /tmp folder content just before shutdown?
I am pretty new to using Ubuntu and want to find a way that I can backup files remotely to my Ubuntu box. My Ubuntu box is running at work and I want to backup files from home automatically every night.Also which solution encrypts the data en route? For example a server with multiple clients with different directory paths.
I'm looking for way to automatically backup a few machines to my server. Does anyone know a good guide to set this up? I want it to pull the files from the machines at a certain time every week.
I have two shares in total and there are also two external hard drives. The server is used by two different organisations that are not supposed to have access to the data of the other one(at least not as normal users).he script I need should run in the background of the server and when a drive is plugged in, it should check, which organization the drive belongs to, and depending on who the drive belongs to, backup the respective share.When the drive belong to neither, it should just do nothing.Unfortunately, I have no clue about scripting and so this makes writing a script like that, at least for me, impossible.So I wanted to know if somebody could name some good websites for learning to write such a script or give tips.
Logout, Suspend and hibernate works as it should in my gnome-shell desktop.But Shutdown/Restart does not - I just get back to my kdm login screen again...how do I enable this ?
I was working on a shell and got some weird exceptions in my program.Just as a reference, I want to save all that is there on my shell to a text file. I do not just want the command history but also all the results that those commands produced at the shell.Is there some built-in utility to do this? I have kept the shell open for now, so that I can take the backup. Also, I am using xterm and it does not allow selecting all the way upto the top of the shell, so the ultimate way is to take the backup one screen at a time.
I try to shutdown a box running Fedora (fc12, all updates applied) remotely. From various threats I selected the following way that suits best to my needs: I edited the entry for shutdown in /etc/passwd: shutdown:x:6:0:shutdown:/sbin:/usr/bin/sudo /sbin/shutdown -h +1
Logging in from a tty with shutdown gives the desired result: The computer does the shutdown. Then I tried the same using sshd and plink: plink -t -l shutdown -pw xxx 10.0.0.123
As a result I get: Using username "shutdown". Access denied Access denied shutdown@10.0.0.123's password:
The /var/log/secure shows the following entry: Oct 2 00:40:46 rotgschirr sshd[6841]: User shutdown not allowed because shell /usr/bin/sudo /sbin/shutdown -h +1 does not exist Oct 2 00:40:46 rotgschirr sshd[6846]: input_userauth_request: invalid user shutdown Oct 2 00:40:46 rotgschirr unix_chkpwd[6847]: password check failed for user (shutdown) Oct 2 00:40:46 rotgschirr sshd[6841]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=rotgschirr.totes-gebirge user=shutdown Oct 2 00:40:48 rotgschirr sshd[6841]: Failed password for invalid user shutdown from 10.0.0.123 port 37195 ssh2 Oct 2 00:40:50 rotgschirr sshd[6846]: Connection closed by 10.0.0.123
Somehow when using ssh the shell /usr/bin/sudo /sbin/shutdown -h +1 cannot be found.