Programming :: Making Sure Only One Instance Of Script Runs Concurrently
Dec 11, 2010
I need to write a shell script that will be run from cron every minute or so. The script will use rsync to keep some folders across several machines in sync. I am very new to shell scripting so some answers might seem obvious but they are not to me:
1. How do I check at the beginning of the script if the script is already running and abort if it is? I saw that most processes use a PID file for that but I am not sure this is the right case for that and in fact how to do it exactly
2. Assuming the list of target machines/dirs to sync are supposed to come from some config file. How should I code that? Just use the normal shell tools that I already know (cut etc) or is there a better way?
View 6 Replies
ADVERTISEMENT
Feb 23, 2011
I am working on the shell using c language. I just would like to ask when I run some command in the backgrounds, how can I allow interleave out? I want to the output like this:
shell> command1
shell> command2 &
shell> command3
[code]...
View 3 Replies
View Related
Nov 22, 2010
Basically, I am provided with a file "temp.dat" with 30 high temperatures (integers) in it. The program is supposed to read them in and compute/print the average. Then it is supposed to print the temperature of each day and, in addition, display a + by each day that is over the average, but only if it is above the average high for three or more consecutive days. This is the part I am stuck on. I'd appreciate any tips that would point me in the right directionFull disclosure: This is a school project. Code:
Code:
#include <stdio.h>
#include <stdlib.h>
[code]....
View 2 Replies
View Related
Apr 27, 2010
I can define all variables in tcl programming in a file for instance var.cfgand source the same file in my tcl script such assource var.cfgIs this possible in perl too?
View 3 Replies
View Related
Feb 15, 2010
I have KDE 4.4 and Firefox 3.6. Whenever I click a link from a plasmoid widget, it tries to open Konqueror and another instance of Firefox. The page actually loads in the opened Firefox window, but the task bar shows an instance of Konqueror and another instance of Firefox, that keeps loading for a while then close. See image below:
I currently have setup the browser default application as "firefox". If I set this option to use the default application, it opens in Konqueror and I don't see additional windows in the task bar. If I change the option to "firefox %u", then it exhibit the same issue, but the process is much faster, so the loading windows don't stay for long in the task bar. Additionally, it opens the link on a new Firefox window and opens the page twice. Although Konqueror is not loaded, the bouncing icon next to the mouse pointer shows up and stay for a while.
View 1 Replies
View Related
Apr 6, 2011
I have two classes, for argument's sake A and B. A implements the core functionality, B is an encapsulated data structure. If you imagine this situation
[code]...
From within B's member functions, I would like to access the public function() in class A. This is not an inheritance issue, they are two discrete classes with radically different functionality. Class A makes an object of B.
View 5 Replies
View Related
Sep 12, 2010
I have a bash script which is called automaticallyI want it so that if when the script is called if a previous instance of it is already running then to delay the running of it until the previous instance has stopped (effectively queue up ./script.sh var1 var2)I have seen some posts about a 'lockfile' but this just seems to stop the second instance running rather than queueing it up to run next (it also needs to be able to queue up a 3rd/4th calling of the script and run them one at a time)
View 14 Replies
View Related
Apr 6, 2011
The intent here takes a little background info.I'm trying to make a basic inventory control to reinforce my studies. It will have a while loop that displays amenu for add, edit, view, and quit. Lets assume the following:
Code:
class inventoryItem:
itsDescriptiveName = None
[code]....
View 5 Replies
View Related
Jul 13, 2010
I have written a code in which i have used vectors:
vector< vector<double> > arr;
arr.resize(x,vector<double>(x,0));
x is a variable which is taken from a very beg text file > 64MB
first line of my code is
cout<<"
Wait Running...";
my code takes text file as an input, takes its data and generates an output text file....
Code is running fine for small data tried till x= 10
but while trying to run with large data ie x = 5000000 approx it is giving error
Even the first line of the code is not displayed. NOTE: variable is declared global but its size is defined in main.
The error that i am getting after approx 2-3 minutes is:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Wait Running...Aborted (core dumped)
View 6 Replies
View Related
Oct 13, 2010
I have a launcher for Quake that essentially runs a shell scripts that runs quakespasm with certain options. Is there a way to add it to AWN?
View 6 Replies
View Related
Jan 24, 2010
I'm a newbie on Linux and currently in the process of installing it. I'm planning to install the latest version of Apache, MySql, and PHP on the machine with a debugger on it. I haven't decided which debugger is suitable for this environment since I don't have any experience on it.
View 5 Replies
View Related
Aug 3, 2010
I am trying to implement a corba program (client) to retrieve customerinformation from the server. Since the server allow to login once andperform your operations until the lifetime experies, i want the client to use already login connection to perform the retrieve function withoutlogin in to the server for every request.Suppose retrieve has three functions, logon(), perform() and logoff()Pseudo code;Quote:
1. User runs a client application
./retrieve <URI> <customerID>
2. if the client program has already login, donot login, go to 4
[code]....
View 3 Replies
View Related
Mar 11, 2010
I hope someone can help me with this. I need to call the same thread multiple times, but only run one thread at a time. So what I do is create the thread which runs then drops out. Run the main loop and after some time pthread_create the same thread again. So in pseudo code
[Code]...
I always presumed if I run a thread and it reaches with a pthread_exit, then the thread was destroyed? However I've found that after I've created the thread several 100 times the programme crashes? So can anyone advise how I call the same thread over and over?
View 10 Replies
View Related
Dec 28, 2008
I wanna that the pc starts (on/off), the pc arrives to gdm. It waits for an user to log.But but at the boot of this machine, I would like that an user has a script started in the processes (NO X cuz bash script).How can an user runs a script at boot of the PC ? (once only and no one loged)
View 4 Replies
View Related
Dec 7, 2010
I used wait4 to time a child process. but the results differ each other dramatically. why?my core source code lists as below.to the point: in linux 2.6 kernel, how to time a process with a high precision. and, only its user-time rather than the elapsed time???
static struct rusage ruse;
static pid_t u_pid;
int main(int argc, char *argv[])
{
int i;
code....
View 14 Replies
View Related
Jan 19, 2011
I am tasked with setting up 3 out of the 6 servers and dividing up 500GB of space in the most efficient manner amongst the 3 servers. The space is in a pool which can be assigned to virtual drives. Each virtual drive can be assigned as disk0 or disk1 and so on to one or more servers. They'll be running CentOS.
On the second try I came up with this scheme:
shared sda1 -- /boot (ext3)
shared sda2 -- /home (ext3)
[code]....
View 5 Replies
View Related
Jun 7, 2010
I'm trying to do a shell script which are suppose to run a program as a specific user at system boot up. The problem is that I don't know for sure how to make the script add the users password to the prompt when it's necessary.
Basically the program would be run like this:
sudo -u extrema program_name -r /srv/program_name -d
and in this example the password is, "hidden".
How would I make this script run this program as user extrema with the password "hidden" at boot-up? I know how to put the script in the rc.X directory and so on, its more the syntax of the code.
View 4 Replies
View Related
Jul 18, 2011
I want to find a desktop application or command line tool to show two different timezone concurrently under LINUX.
Anyone knows there are such application?
Say i want to know the time at london and USA at the same time. (different time zone)
View 4 Replies
View Related
Nov 17, 2008
I need to write a batch file for windows that automatically starts the cygwin tool in windows and executes the unix scripts.Previously we had these scripts in unix server.Now we need to migrate them to Windows server.For this reason we are using cygwin tool that allows the scripts to be executed on Windows server.We had written a batch file that starts the cygwin tool,but we were not able to execute the unix scripts.How can we write a batch file such that it executes all the unix scripts in cygwin.
View 5 Replies
View Related
Sep 29, 2010
Making an awk script. If you tell me to read the documentation.. I know.. you're right.
By the way, here is some input
Code:
My awk program has to work in this way:
until the end of the document if the beginning of the line is "START11" while the beginning of the line is different form "END11" print the whole line (print the "END11" line too)
View 1 Replies
View Related
Dec 1, 2010
I am trying to understand how can I make a graph in C. So I wrote some program.
Code:
#include "declarations.h"
graph root = NULL;
int main()
{
[Code]....
View 6 Replies
View Related
Apr 10, 2010
How can one draw a circle in c++ without making use of BGI.
View 4 Replies
View Related
May 3, 2011
I'm trying to create something like this:[URL]...when you press "fire" you see the graphic.My program already does all the math, but what i want is that animation of the projectile moving depending on the entered data.i really don't know how to accomplish that.I'm using Gtk#.what would i need to create something like that??
View 1 Replies
View Related
Jul 28, 2011
was making a scrambler from python and this is what i have
# Scramble word re-arrange characters
import random
scrambler= raw_input("put a word and i will unscramble:")
[code]....
View 9 Replies
View Related
Jun 8, 2010
I need to write a script that will take 1 command line argument. The argument will be a username. The script will determine if the user exists on the system and will print an error if it does not. If the user does exist it will determine if the user is currently logged in, if the user is not logged in it will determine the last time the user logged in and display the file in the users home directory that was most recently modified.
View 2 Replies
View Related
Mar 22, 2011
This is probably hopelessly ambitious as I'm not a C or C++ programmer (I normally like to stick to scripting languages like BASH or Perl). Basically I'm looking on good advice to get me started with writing a Application Dock with the functionality of the OSX dock but without the overly flamboyant graphics that have characterised the Linux versions.At the moment the closest I've found to what I would like is bbdock. However it falls well short of the functionality of what I would like.
What bbdock does is read a file to create an icon for the openbox dock/fluxbox slit/wmaker whatever that launches an application when first clicked, shows an little arrow when the application is running, and brings the application to the fore when clicked once running.Here's a screenshot of it doing just that.The drawback to bbdock is that it doesn't really look for running applications, only those launched from bbdock. So for example it wont notice if I've launched an instance of pcmanfm from the openbox menu. And therefore it obviously also doesn't add icons for other applications that are running.
What I would like to be able to do is detect new running applications and add a bbdock icon for them. Also to detect if an application already with a shortcut has been run and update it's status to show it's open. Probably have an up and down arrow to move the icons up and down when there are too many to fit on the screen. None of the above needs fancy animation. The fade to gray effect used by bbdock is quite nice and could probably be augmented with a fade in and out to grey to represent another action, say fading to grey and back when launching and greyed when iconified.So, my question is what do I need to get started doing this? Am I best using the pretty outdated bbdock wmaker dockapp style? What functions and libraries am I likely to need to achieve the effects I want? Are there any examples of how to monitor running applications (well windows and figure out what constitutes a new application) that I could look at for inspiration. Is there anyone who's into C++ for linux who would be interested in helping me out to get this small project working?
View 8 Replies
View Related
Mar 18, 2010
I need to find the value of:
Code:
$Namenumber
My script asks for the name you want to look up and I want it to return the value of $Namenumber
I was thinking:
Code:
number=$"$name"number
but this returns
Code:
$Namenumber
but does not actually resolve what the variable $Namenumber is equal to.
View 4 Replies
View Related
Jun 7, 2010
I have a LAMP based web hosting account (BlueHost). I have an existing simple MS Excel application which I would like to make it web based. However I am not sure what tools or features of PHP are out there that will aid me with this task. Here are some details:
1. I don't want to create an entire Excel program online. For that there are plenty of existing applications like Google Docs, MS's own online version of Excel, etc.
2. My current excel file uses some of the following excel functions:
a) SUM
b) Product Sum
c) Conditional Formatting (like changing font color if an amount is below a threshold, etc.)
d) Sorting (Date, Amount)
e) Drop Down Box to select pre-defined values
3. Ability to add/delete/modify a entry (row)
4. I don't care whether the application has the same look-n-feel as MS Excel.
As you can see it is a very simple home grown excel application with few basic mathematical functions. Here are some few thoughts that I have currently in my mind:
i) Just start coding intuitively as you would develop a normal web based application.
ii) Do (i) but use some of the PHP's excel oriented helper functions (COMs?) if there are any
iii) Use completely a different set of tools permitting that they run on LAMP environment.
I could have started with (i) but before making a costly mistake I thought I would get some opinion from the community to see if this is the right approach.
View 1 Replies
View Related
Jan 14, 2011
I'm building a debian source package to upload on my launchpad PPA. Does anyone know what file I should create or edit to make a menu entry for the app? Or a link to some *specific* doc? (The debian doc is quite overwhelming...)
View 2 Replies
View Related
Jun 25, 2010
I'm trying to make my first c project (a simple tic tac toe console game), and I am wondering how to make a final product (copy all source code files to a distribution folder upon compilation). Should I use a bash script or should I use a makefile to make the distribution folder? I'm not terrible familiar with either; I have a basic makefile to make an executable, and that's about all I know of make.
And if I do use a bash script, how do I copy over source code files? I tried cp ./*.c and cp ./*.h, but I think the script read it literally as moving a file named ./*.c (and ./*.h), and couldn't find it.
My makefile is pretty much this:
Code:
objectFiles = main.o io.o board.o game.o
ttt : $(objectFiles)
cc -o ttt $(objectFiles)
View 2 Replies
View Related