Sponsored Content
Top Forums Shell Programming and Scripting Running function or command concurrently in a bash script Post 302278092 by dj_bridges on Monday 19th of January 2009 09:00:01 AM
Old 01-19-2009
CPU & Memory Running function or command concurrently in a bash script

I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place, the system checks if the tunnel is still up and if not it resets it. I though I had it cracked (see below), but even though the $BREAK variablet change after the process code had run, it didn't escape the while loop so the script never ended. I therefore think I need a different way of doing it (by the way I am new to scripting so expect some ugly code).....

I am not asking someone to write this for me, but if you know of a function that I could use that would be most helpful..... Thanks in advance.....

Code:
function process ()
{
process code.....
BREAK=500
}

# ------------- the script itself --------------------------------------
BREAK=0

# First run Tunnel to get it up and running (a separate script).
Tunnel.sh

# Run process and the while loop at the same time.
process &
while [ $BREAK == 0 ]
do
   Tunnel.sh #Re-establishes connection if required
   sleep 15
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running same script multiple times concurrently...

Hi, I was hoping someone would be able to help me out. I've got a Python script that I need to run 60 times concurrently (with the number added as an argument each time) via nightly cron. I figured that this would work: 30 1 * * * for i in $(seq 0 59); do $i \&; done However, it seems to... (4 Replies)
Discussion started by: ckhowe
4 Replies

2. UNIX for Dummies Questions & Answers

Alias, function or script (bash) to "revert" cd command?

In all of my brief and superficial experience with Unix or Linux, the one curious and consistent thing has been that 'cd ./' (back up one directory level) has done absolutely nothing in any of them. Now I understand that, at least for bash, 'cd ./' appears to have been substituted by 'cd ..' Am... (1 Reply)
Discussion started by: SilversleevesX
1 Replies

3. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

4. UNIX for Dummies Questions & Answers

How to run script concurrently

Hi all, I have one script. Its job is to get 1 file from dirA and 1 file from dirB as parameters for another python script. However, there are a lot of files in both dir A and B, so running this scripts really takes a lot of time. So I wonder if there are any ways that I can do this faster,... (6 Replies)
Discussion started by: yoyomano
6 Replies

5. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

6. Shell Programming and Scripting

Function not running in script.

I an using the below functions in my script. --------- checkRT() { subHeader "Runtime Check" for nn in `cat $HOST_FILE|egrep -i 'msdp|ca|backup|db'|grep -v '#'|sed '/^$/d'|awk '{ print $1":"$2":"$3}'` do fhba=`expr $nn|cut -d: -f2` fhba2=`expr $nn|cut -d: -f3` subSubHeader $fhba2 ssh... (1 Reply)
Discussion started by: nandan8a
1 Replies

7. Shell Programming and Scripting

Script function which checks if itself is already running

Hi All, I have a cron job set up which is set to run every 10 seconds. What I need to do is have the script do a check to see if it is already running such that if it is running it wont fire up additional instances and processes according to its normal process. For example if I have a script... (4 Replies)
Discussion started by: landossa
4 Replies

8. Shell Programming and Scripting

Command not found, but using function in bash

In the bash below, if the answer is "y" then goto function remove. If the answer is "n" then goto the id variable line (where the date is inputted). However, I am getting command remove not found, but remove is a function not an command. I must have the syntax incorrect? Thank you :). ... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

[bash] running a function remotely using ssh

Hi all. I need a bash script to run a function remotely. I think it should be similar to the following but can't figure out the exact syntax. Here is the script: #!/bin/bash function nu () { for var in {0..5}; do printf "$var, "; done; echo } ssh host "$(typeset -f); nu" ... (9 Replies)
Discussion started by: ziguy
9 Replies

10. UNIX for Beginners Questions & Answers

Need a Bash script for iterating thru an array and running a command

Hi , I am a total beginner so bear with me. I have the below code which works . I need to extend it by iterating thru the array arr and executing a command in each loop. some thing on the lines of below. I need to run this in a Jenkins script , so I would need below bash script to run... (6 Replies)
Discussion started by: SVRao19056
6 Replies
GOGOC(8)						    BSD System Manager's Manual 						  GOGOC(8)

NAME
gogoc -- gogoCLIENT SYNOPSIS
gogoc [-h] [-?] [-y] [-n] [-b] gogoc [-f config_file] [-i interface_name] [-u interface_name] [-s interface_name] [-r retry_delay] DESCRIPTION
gogoc provides a means to configure a tunnel obtained from a tunnel server that supports the tunnel setup protocol (TSP). gogoc will connect to a tunnel server and request a tunnel according to the specifications given in the configuration file. As a background process, it will then monitor the state of the tunnel. In the event of a timeout, gogoc will establish a new tunnel. gogoc currently supports three types of tunnels: - v6v4 (IPv6 over IPv4) Supported on FreeBSD, NetBSD, OpenBSD, Linux, Windows, Solaris, Darwin and OpenWRT. - v6udpv4 (IPv6 over UDP over IPv4) Supported on FreeBSD, Linux, Windows, Darwin and OpenWRT. - v4v6 (IPv4 over IPv6 (DSTM)) Supported on FreeBSD and Windows. ARGUMENTS
The following options are available: -h, -? Displays a short usage summary and quits. -y Automatically accept server's public key. -n Run as a foreground process. -b Stop trying to reconnect upon first error received. -f configuration_file Specifies a different configuration file. Default is /etc/gogoc/gogoc.conf. -s interface_name Overrides client_v4 in gogoc.conf(5) -i interface_name Overrides if_tunnel_v6v4 in gogoc.conf(5) -u interface_name Overrides if_tunnel_v6udpv4 in gogoc.conf(5) -r retry_delay Overrides retry_delay in gogoc.conf(5) SEE ALSO
gogoc.conf(5) http://www.gogo6.com ACKNOWLEDGMENT
This software uses code taken from other organizations as : - RSA data security for md5. - The Apache Software Foundation for Base64 encoding and decoding. AUTHORS
gogo6 Inc. http://www.gogo6.com support@gogo6.com gogoCLIENT May 7, 2007 gogoCLIENT
All times are GMT -4. The time now is 08:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy