Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Script in Background

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
miciomacio
Posts: 5
Joined: 2014-10-05 02:40

Script in Background

#1 Post by miciomacio »

Hi all, I'm working on a script sh or bash that will make simple tasks like moving files or insert rows in mysql db, I wanted to ask, since the program must always be active if there is a way to create a script not tied to the terminal from which it is launched and it works like a demon that is completely in the background.
Thanks

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: Script in Background

#2 Post by saulgoode »

Start your command with nohup.

Code: Select all

nohup somecommand &
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

miciomacio
Posts: 5
Joined: 2014-10-05 02:40

Re: Script in Background

#3 Post by miciomacio »

First of all, thank you for your response.
But I was looking for a method in script to do this,
currently my code is very simple:

Code: Select all

while inotifywait -e modify /var/log/proftpd/xferlog; do
      #my function es.
      #php /var/www/index.php
done
The problem is that inotifywait has the ability to be launched in backgorund "-d" but only if saves the actions in a log file and without being able to perform operations.
Is possible edit the script for execute all process (cicle including) in background?

It may seem like a silly requirement, but the script is intended to implement other function and this would be a helpful feature. Thanks

Post Reply