Tuesday 4 March 2014

Job Scheduling with 'at' command in Linux Ubuntu

"at" command takes an argument time on which the job is executed and then displays at $prompt.
example:-

at 17:00
then press enter.

at 5:00 pm
then press enter

at>sh.my.sh
then press enter
In above command it will execute my.sh file at 5 pm.

these above at command will be executed in $ prompt.
Ctrl+d to exit from at prompt.

Note:- The "-f " option is used to take commands from the file and "-m " option is used to send jobs completion report to the specified user.

at -m -17:00
then press enter.

Note:- "at" command also offers may keywords like now,noon,today,midnight,tomorrow and also accepts
+ symbol to act as an operation.

example:-

at now +1 year
then press enter

at 5:00 pm +1day
then press enter

at 5:00 pm December 25,2016
then press enter

at 10 am tomorrow

Note:- The jobs list display with "at -l" command.

"at -r" command is used to remove all the jobs from the list. 

Monday 3 March 2014

How to assign permission remove permission to a file

"chmod" command is used to set file permissions in Linux.
we can also use six different options for assign permission or remove permission -
for assign permission to file we can use =
+r
+w
+x

for remove permission to file we can use =
-r
-w
-x

example :-

chmod +x abc.sh

How to execute a job below low priority with nice command

nice -n
nice -n 5% server.out
nice -n 15% clint.out
cc my.c -0 my.out

in above command -0 is used to produced user define output file.
./my.out
for execute out file
pwd then press enter

Job execution with low priority with nice command

All jobs in linux or unix platform normally executed with equal priority which is not desirable because high priority jobs  must be completed all the earliest.
the "nice" command is used with "% sign" to reduce the priority of the job.
Note:- the "nice" vlaues are system depends and typically use "nice" values from 1 to 19.
Commands -

the ps -0 nice

this above command display nice values which are supported by operating system. 

For loop syntax in shell script

with the help of this post you can also know that how to use for loop in Linux Ubuntu.
syntax of for loop in shell script:-

for((initialization; condition; increment/decrements ))
do
------------------
------------------
------------------
------------------
done

While loop syntax in shell script

with the help of this post you can also know that how to use while loop in Linux Ubuntu.
syntax of while loop in shell script:-

while test condition
do
------------------
------------------
------------------
------------------
done 

How to use system variables in Linux Ubuntu

If we want to use system variables then see following example:-

set 10 20 30

echo $1

output = 10

in above given small program we can see that set keyword sets the system variables values and when we echo $1 then it prints our set variable value.

In linux when we pass parameter in shell script then Linux automatically create a variable $#.
$# counts total number of command line argument which has passed.