So I read in viewtopic.php?f=15&t=999 that it's not good to edit a bash script while running, however I would like to know if it's ok if I keep the line numbers of the statements and just add something to it.

I'm pretty sure that editing the script while it's running won't really hurt. The only problem is that the script is already in memory, so your changes aren't going to be applied until the next time the script is run.

So essentially, you can make the change to the second task, while the first/long task is running, but that change won't actually make a difference in the current run of the script.

As far as timing the run goes, you might want to take a look at the 'time' command!

Something along the lines of 'time ./execute_task' should give you the total elapsed time it takes to run that task.

Personally I've had some very bad experiences with changing running scripts and therefor recommend to never ever ever do that. The last time is some while ago (~5 years?) so I'm not sure if things have changed in the mean while. It's just too unpredictable what will happen when you do.

About your other question regarding an estimated time, you could use something like this:

Then after each 'long running job' call this with 4 parameters: o The time when your script started (in unix/epoch seconds) o The time now (in unix/epoch seconds) o The number of long running jobs that are finished o The total number of long running jobs that have to be processed

I'm pretty sure that editing the script while it's running won't really hurt. The only problem is that the script is already in memory, so your changes aren't going to be applied until the next time the script is run.

Not true. Consider this script:

Code:

#! /bin/bash

echo 'Edit me!'

sleep 20

echo after

echo DONE

When I run it, edit it (just adding the word "dude" before the exclamation mark) while sleeping, I get this ouput:

Code:

edit me!./1364.bash: line 6: p: command not foundafterDONE

It might depend on the editor, how it handles backups and so on, but it is dangerous.

Probably won't work while running, at least not very well as others have posted above.

I had a bash script that had a function that "sourced" in code, that could be edited on the fly as it was sourced in every time the function ran, so I was able to make changes "on the fly"..... but it was coded that way ahead of time. (actually it was jbsnakes and my code in bashbot, it allowed us to "load" and "unload" different "modules" for the irc bot). But again, it was coded with that in mind from the start.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum