Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I know there isn't a such thing, but is there something similar.
I have a website which runs on a dedicated server, and have several domains. I want to replicate the main website across all of the other domains automatically during the night. To do this, I need some sort of file that has all the commands in it. i.e. copy contents of one folder to another etc etc.
anyone explain how to do this? do I simply just put the commands in a file?
What you want is shell scripting. Basically, you just put all the commands in the file, but you need to make sure that the first line of the file is
#!/bin/bash
This is a bit of magic that tells the system to execute the file using the BASH shell. (You can use something other than BASH if you want, just put the path to the relevant interpreter).
There's a very good introduction to shell scripting here, and you'll find plenty of info on this site about it as well.
To get the script to run automatically every night, you'll want to use cron. See the manpages for more information.
ok, I created a file and got it to work, but now it wont work anymore. I've copied each line, line by line and pasted them 1 by one and they worked, but when I put them in the script file, it doesnt. All the folders are correct, because I've ran this line by line
heres what I get :
[root@oakley-travel home]# ./replicate.sh
: bad interpreter: No such file or directory
[root@oakley-travel home]# chmod u+x replicate.sh
[root@oakley-travel home]# ./replicate.sh
: bad interpreter: No such file or directory
[root@oakley-travel home]#
I've copied the script and pasted it into a new file called replicate2.sh, and it worked perfectly fine! Very strange
I don't know what's going on there. It may be some other permissions issue, or it could be something else entirely. If you want to try and work out what's going on, I'd guess a good starting point would be comparing the permissions on the two scripts.
Alternatively, you could class this as "Just one of those things" and ignore it
Where is the script located, and how is that partition mounted? Some partitions, especially ones that are world writable should not allow execution of programs and are mounted with the "noexec" option.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.