The best way to ensure only 1 copy of bash script is running?
location: linuxexchange.com - date: November 11, 2009
What is the simplest/best way to ensure only 1 copy of given script is running - assuming it's bash on linux?
At the moment I'm doing:
ps -C script.name.sh > /dev/null 2>&1 || ./script.name.sh
but it has several issues:
it puts the check outside of script
it doesn't let me run the same script from separate accounts - which I would like sometimes.
-C checks only first 14 characters of process name
Of course I can write my own pidfile handling, but I sense that there should be some simple way to do it.
best way to automate shell commands shell script or python scripts or something els
location: linuxquestions.com - date: August 8, 2012
I want to automate a few shell commands. I want to compile my program for different options and run it. These options are stored in a file.
So, I am supposed to read all the options from the file.
Compile a particular program with one option at a time.
Run that program.
Then compile again with another option from the file.
Do this till all the options in the file are exhausted.
I am not sure, what is the best way to automate this. Should I write shell scripts or should I try python script or something else.
Best Way to Make Exact Copy of Zip Disk
location: ubuntuforums.com - date: January 18, 2009
Ubuntu/Linux is a terrific OS but there are so many ways to do everything that we newbies sometimes want to tear our hair out. So here's a real basic newbie question to address a very specific situation -- and hopefully I'll learn a little more from the answers.
I have a bunch of Zip disks that were created on a Mac G3 -- most or all of them on System 9 or earlier, I think. Some of the disks seem to have data that is hidden from Nautilus -- at least the amount of total data reported is greater than the sum of the files I can see.
Before I do anything else, I would like to make bit-for-bit clones of these disks and burn the resulting images onto CD (or DVD) so we can try looking at them on a Mac, with System 9 if necessary. But when I search for help on disk images, I quickly find myself buried in possible alternatives with no idea how to start choosing one.
What's the simplest, most straightforward way to do this in Intrepid? I'd prefer to use the GUI, but I'm happy using the
Easy Way To Backup Your System!! (Bash Script)
location: ubuntuforums.com - date: March 5, 2010
WARNING: NO CODE IS FLAWLESS, AND THIS IS NO DIFFERENT.
THINGS MIGHT GO WRONG WHEN USING THIS METHOD, SO I SUGGEST TAKING A HARD-COPY (ON CD/DVD) OF ANYTHING THAT YOU REALLY CAN'T AFFORD TO LOSE.
THIS IS MEANT ONLY AS A STARTING POINT, AND YOU SHOULD LEARN A BETTER WAY AS YOU GET MORE INTO USING UBUNTU.
THIS SCRIPT COMES WITH NO WARRANTY OR GUARANTEE OF ANYTHING. THOUGH I WILL HELP ANYONE WHO ASKS FOR IT NICELY IN ANY WAY I CAN.
I understand how frustrating it can be to come from an OS like Windows, to something as excellent as Ubuntu.
Your so used to Windows that it all seems very new and frightening.
Well, Don't give up!!!
It gets easier, and along with that it gets BETTER than Windows ever got.
You'll never want to go back...kinda like...nahh i better not
In this article, I'm going to show you how you can backup your entire system.
Not only that, but I'm going to show you how you can create a BASH script to do it for you, and how to add
Bash Script Running Different Commands for Different Versions of Apache
location: ubuntuforums.com - date: December 31, 2012
I'm trying to write a script that will basically run different commands for versions of Apache. For Apache 2 I just need it to run command. If the version is Apache 1 I need it to check if the output of a given command returns blank and check if a file exists. I want the code to exit 0 because these are considered fail conditions.
More specifically what I am trying to accomplish is this.
If Apache version is 2 then run a command and if it does not contain the 'apache2' string then exit. Else if the apache version is 1 then check if a command output is not blank or a file is a regular file. I used /etc/passwd as a dummy file. If either condition is true I want the code to exit.
Any pointers would be appreciated. Thanks!
VERSION=`apache2 -v | grep "Server version"`
ENABLED=`ps -A | grep 'apache2'`
if [ $VERSION == *Apache/2* ];
elif [[ $ENABLED == *"apache2"* ]];
echo 'Apache service is enabled'
bash script running from cronjob command not found
location: linuxexchange.com - date: January 1, 1970
my crontab is as follows:
01 04 * * * root /home/sphinx_scripts/daily_update_index.sh
daily_update_index.sh is as follows:
indexer --rotate xxx
now if I run /home/sphinx_scripts/daily_update_index.sh from anywhere(as root), it works fine. But I get emails daily from cron job saying "command indexer is not found". the full path of the indexer is /usr/loca/bin/indexer. Why would I get such an error?
Quickanddirty way to ensure only one instance of a shell script is running at a time
location: linuxexchange.com - date: May 26, 2009
What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?
[SOLVED] Bash Script to copy files to SAMBA Share
location: linuxquestions.com - date: July 2, 2008
So I have 1 server at home and one network storage device. I want to move files from my server to the network storage device via SAMBA through a bash script. I was wondering if anyone has an example of how this might be done. The following link provides me with the method to connect to a SAMBA share and mount the SAMBA share as if it were on my file system: REDHAT SAMBA - CONNECT TO SAMBA SHARE FROM THE COMMAND LINE I am however unsure of how one might go about un-mounting the share? The following commands will assist in searching and connecting to a SAMBA share:
Lists available Samba Shares in your Network
bash script? how to rename files in random way?
location: linuxquestions.com - date: May 10, 2006
I have a lot of photos that I need to put into a random-order slideshow. Easiest would be to just drag-and-drop the whole lot. Is there any way to scan a directory and batch-rename a group of files into random names, but keeping the extension? (.jpg in this case)
How do I execute a bash script from a link on a web page? Is there any way to do this
location: linuxquestions.com - date: March 10, 2010
I have a website that I can host and store my scripts. I want to be able to just click a link and have the computer that is clicking the link do one of two things:
1. open gnome-terminal and execute the script that is stored on the remote server, or
2. download the script, make it executable, and run the script locally
3. if I need a hybrid of the two, that's fine by me.
I have searched possible answers and solutions using Google searches on bash scripts, executing php, html codes, and anything else I could think of with no success. Thanks in advance.
Page: 1 2 3 4 5 6 7 8 9 10