Qnx systems use of cron and contab by Frank Amore

Дата канвертавання25.04.2016
Памер10.91 Kb.
QNX systems use of cron and contab by Frank Amore
In QNX one can use a standard subroutine that performs tasks on a time base.

The name of that subroutine is: cron

The name of the file that contains the info for cron is: crontab.
An example of it's use:

I have received a request to dream up something that would purge the video print spool after a period of time has elapsed.

The reason for the request is, that if the printer is broken or disconnected or the papertray is empty, all print requests are re-directed to the print spool buffer. The print spool buffer can hold multiple old pages.

If the printer is re-connected or if the paper tray is filled,all these old pages will be printed. This can take some time and a lot of paper.

Another example:

On a Smart Single Point color frame, every measurement of every sensor is stored in a so called date.csv file. Every shade for every day is saved and this information needs to be cleared manually if disk space becomes an issue.

It would be nice if there was a utility that would do this automatically on a time basis.
As an example I have added a crontab file that will do the trick for both operations. One file doing both? Yes! The reason is that the utility cron can only handle one crontab file, but a crontab file can contain multiple tasks.
The example crontab file.

The file can be located in any directory, but for back-up purposes it is wise to put it in a directory that is in fact saved during a backup.

If that's the case, your special modifications will recover in case of a system re-build (eg. After harddisk failure)

The directory of choice is /products/color/config.

So let's open up a terminal window and login as root, change to directory /products/color/config and start vedit (some basic knowledge on how to do all this is assumed available...) i.e.

“cd /products/color/config” Don’t actually enter the quotes(“).

“vedit crtb.ser” Don’t actually enter the quotes(“).
Create the following ASCII file using vedit:
#***** crontab file crtb.ser 17feb00 ser


#***** This crontab routine clears the lp spool buffer

#***** (all files older then 20 minutes)

#***** cleaning is done every 10 minutes,

#***** starting at 1 past the hour)

#***** and

#***** clears all measurement data files

#***** (older then 30 days)

#***** for both top and bottom sensor

#***** cleaning is done every day at 06:00

#***** If you only have one sensor, delete the

#***** line for the non-exsisting sensor


1,11,21,31,41,51 * * * * find /usr/spool/lp -mmin +20 -exec rm -f {} \;


0 6 * * * find /products/color/data/dos/top -mtime +30 -exec rm -f {} \;

0 6 * * * find /products/color/data/dos/bottom -mtime +30 -exec rm -f {} \;


#***** crtb.ser end

save this file and name it crtb.ser (if started vedit with this filename, just answer yes to save)

Make the file executable by issuing the

following command:

“chmod 777 crtb.ser” Don’t actually enter the quotes(“).

Next, the system has to be told to start the cron program at startup and have it run in the background.

This is done in /etc/config/sysinit.1 i.e.

“cd /etc/config” Don’t actually enter the quotes(“).

“vedit sysinit.1” Don’t actually enter the quotes(“).

You will have to add a line after lpsrvr &

The new line should read:

Cron &

Save and exit vedit.

After that, the system needs to know where to find the crontab file

This is done in the file /products/color/config/colorStart

“cd /products/color/config” Don’t actually enter the quotes(“).

“vedit colorStart” Don’t actually enter the quotes(“).

After the fi command add a line with the following:

crontab -u root /products/color/config/crtb.ser

Save and exit vedit.
Well, that's it.

Restart the system and verify that cron is running, with the command

“crontab -l” Don’t actually enter the quotes(“).
For a test, power down your printer and request multiple hard-copies.

Check your printer spool files in /usr/spool/lp (you may list the files in the directory by typing “ls -l”)

Wait 30 or so minutes and check the spool files again; all files older then 20 minutes should be gone again.

Power up your printer.

To check your csv files, come back the next day (at about 07:00) and verify that every csv file, older then 30 days is gone. (You may list the files in the directory by “ls –l”, this will also give you the date the file was created). Any commands that you wish to have more information about you may type "use” before the command in question. Don’t actually enter the quotes(“).

Additional information regarding crontab may be found by typing the command:

“use crontab” from a terminal window. Don’t actually enter the quotes(“).

Good luck

База данных защищена авторским правом ©shkola.of.by 2016
звярнуцца да адміністрацыі

    Галоўная старонка