View Full Version : "$at", and "$command &"!!


elsheikhmh
hi all,
i have two questions, relating to bash, i use redhat 7.2, BASH_VERSION 2.4
1- THE BACKGROUND PROCESSES. as i know, placing an ampersand (&) after any command, forces the process to be a background one, e.g. "$ls &". the o/p of this example should be the PID of that process, then i can inquire about the process by "$ps PID". but amazingly, the output is the same of $ls without (&)!! what is the problem? is my book an old one? i know that one excellent property of linux is the inheritance of all old features beside the new ones!
2- THE BASH COMMAND "at", requires UTC time formate, i do not know what is UTC time? the man page doesn't contain examples (this is usually great problem for me with all man pages) can anyone give me a web link to man pages with examples?

alaa
when you put an & in front of a command it is pushed to the backgound, but this doesn't mean that it will not use the terminals standard input and output.
so what happens is that bash does print the PID but ls also prints lots of stuff and the PID gets lost in the way, to see what I mean just redirect ls' output somewhere else this way.

ls >> /dev/null &

no you should be able to see a message like
[1] 8816

however relying on the output is a stupid way to get the PID you should instead use the special variable $!.

when you run a command in the background its PID is stored in $!, so try this

ls &
echo $!

>THE BASH COMMAND "at", requires UTC time formate
there is no bash command called at, at is a standalone command to check this try

which at

you should get something like
/usr/bin/at

and I searched the at man page and found nothing about UTC at all, where did you read that??

here is what man says about the time format to use

At allows fairly complex time specifications, extending the POSIX.2
standard. It accepts times of the form HH:MM to run a job at a spe-
cific time of day. (If that time is already past, the next day is
assumed.) You may also specify midnight, noon, or teatime (4pm) and
you can have a time-of-day suffixed with AM or PM for running in the
morning or the evening. You can also say what day the job will be run,
by giving a date in the form month-name day with an optional year, or
giving a date of the form MMDDYY or MM/DD/YY or DD.MM.YY. The specifi-
cation of a date must follow the specification of the time of day. You
can also give times like now + count time-units, where the time-units
can be minutes, hours, days, or weeks and you can tell at to run the
job today by suffixing the time with today and to run the job tomorrow
by suffixing the time with tomorrow.


> the man page doesn't contain examples

not so here, try this for size


For example, to run a job at 4pm three days from now, you would do at
4pm + 3 days, to run a job at 10:00am on July 31, you would do at 10am
Jul 31 and to run a job at 1am tomorrow, you would do at 1am tomorrow.


if you need more info my trusty man page say


The exact definition of the time specification can be found in
/usr/doc/at-3.1.7/timespec.


cheers,
Alaa