Tim Evans Linux Tips Page

Tim Evans Informal Home Page | Tim Evans Imperial College page

For general help try Linux in a Nutshell which is online. Also see notes above on running Linux code on Windows.

Running tasks in the background

A task can be run as a background task by putting a & at the end of the command line.

If a task is already running in the foreground, you move it to the background as follows:-

  1. Press CTRL-Z to suspend the current foreground job.
  2. Type the job control command bg to push it into the background, or fg to restart it in the foreground.

To see which jobs are running type jobs -l or use the ps ua command. A background job can be brought to the foreground using fg jn where jn is the job (not the PID) number given by the jobs command output. Likewise stop jn suspends a job, kill %jn terminates a background job.

at batch and cron are all useful commands for scheduling jobs.

Useful commands for controlling processes. These have either PID numbers given by the ps command, or if a percentage sign is given, as in %jn, then the job number jn is involved. which are not the same as any job numbers.


To pack and compress individual files try using gzip files* which produces and individual files*.gz for each file in the list. gunzip files*.gz will unpack them. To pack and compress files to a single file try using tar -zcvf compressedFiles.tgz files.* and to unpack unpack using tar -xzvf compressedFiles.tgz

General Tips

Bash Shell Scripts

The following contains some useful tricks. Note the use of environment variables both externally created (e.g. HOME and TMPDIR) and those created within the script (e.g. ZIPNAME). Also note that there must be NO spaces around the = sign of the export command.
export NAMEROOT=IC090729stempt
export NAMEEND=inputBVNLS.dat
export ZIPNAME=$NAMEROOT`eval date +%y%m%d`".tgz"
mkdir -v ${TMPDIR}/input
mkdir -v ${TMPDIR}/output
cp -v ${HOME}/timgraph/input/${NAMEROOT}${NAMEEND} ${TMPDIR}/input/
echo Running ${NAMEROOT} and zipping to ${ZIPNAME}
java -Xmx100g -classpath ${HOME}/timgraph/dist/timgraph.jar TimGraph.run.MakeLineGraph  :2  -gvet -gdf -gewf -gvlt -gbt -fin${NAMEROOT} -fie${NAMEEND}  -fid${TMPDIR}/  -fod${TMPDIR}/ -o0
#gzip -vc ${TMPDIR}/output/*
tar -zcvf ${ZIPNAME} ${TMPDIR}/output/*
echo unpack using tar -xzvf ${ZIPNAME}.tgz
cp -v ${TMPDIR}/output/*.tgz ${HOME}/timgraph/output/


Used to submit jobs on the HPC Altix machine of Imperial College. Prototype form is
qsub -m abe -M username@host script.sh