views:

42

answers:

1

I've written a simple KShell script to kick off a background task

#/bin/ksh 
#startMonitoring

./detectFile /usr/local/data/testFile > fileHistory &

I run it with the following command

startMonitoring

When I run jobs I get no results, but the command is running and shows up in ps:

512232 pts/0 0:34 /bin/ksh ./detectFile /usr/local/data/testFile

Why can't I see the item in jobs, and how can I change my script so it does show up in jobs?

+1  A: 

The jobs command only looks in the current shell. Scripts are run in their own shell. If you source your script instead, then jobs will show it:

$ . startMonitoring
$ jobs
[1] +  Running                 . startMonitoring
Dennis Williamson