LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2007, 02:16 AM   #1
anandv_1234
LQ Newbie
 
Registered: Dec 2007
Posts: 8

Rep: Reputation: 0
Question How to run a shell script in a background?


Dear Folks,

I wanted to run a particular shell program in a background,
how do we do that...


i have another query also, that is how to find a creation date of the file..

Thanks in advance..


Thanks and Regards,
V.Anand,
Bangalore.
 
Old 12-23-2007, 02:46 AM   #2
the_imax
Member
 
Registered: Apr 2004
Distribution: RHEL 4/ CentOS
Posts: 159

Rep: Reputation: 30
but an & at the end of the command to run it in background

like
./myscript&

this will keep your terminal free and command will keep running in background

I am not sure about the file creation date, may be someone else can help
 
Old 12-23-2007, 03:01 AM   #3
UgoBoss
LQ Newbie
 
Registered: Mar 2007
Location: Genova, Italy
Distribution: Debian
Posts: 7

Rep: Reputation: 0
Quote:
Originally Posted by anandv_1234 View Post
i have another query also, that is how to find a creation date of the file..
This is not possible: unix stores only time of last access, time of last modification and time of last inode change
 
Old 12-23-2007, 03:03 AM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Note that for most commands, if you run them in the background using the & after the command, they will terminate when the terminal is closed. This is because the operating system sends the SIGHUP (hang up) signal to background jobs when a terminal closes, and mos programs terminate on receipt of this signal.

You can prevent the signal from getting to the program by starting it like this:
Code:
nohup command &
The nohup stands for "no hangup", referring to the signal mentioned above.

As for the time, unix-like filesystems do not store the creation time for files. You have three time stamps to choose from:
  1. atime - the time the file was last accessed (e.g. read)
  2. mtime - the time the file contents were last modified (e.g. appended to)
  3. ctime - time of last change to the file contents or the file meta-data (e.g. permissions change).
Probably the one you want is the mtime. You can get this for a specific file using the stat command, like this:
Code:
stat -c %y filename
Of using the -l option to ls will also display the mtime, although the format changes more, so if you are trying to use it in a script, the stat method is probably more suitable.
 
1 members found this post helpful.
  


Reply

Tags
atime, background, bash, chmod, ctime, mtime, permissions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script switching it self into background process knockout_artist Linux - Software 3 11-24-2007 11:33 AM
Restrict a Shell Script to run from a shell bharaniks Linux - Security 7 08-26-2007 10:57 PM
how do i get a shell script to run in the background? tjyorkshire Programming 4 07-06-2007 02:28 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 05:40 AM
How to run a bash command in the background from perl script professorfrink Programming 3 11-13-2003 03:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration