published by whitemice on Mon, 10/21/2019 - 09:36
In some effort to avoid time-zone drama, or perhaps due to fantasies of efficiency, some developer put a date-time field in a PostgreSQL database as an integer; specifically as a UNIX Time value. ¯\_(ツ)_/¯
How to present this as a normal date in a query result?
published by whitemice on Wed, 09/11/2019 - 11:09
Dates in databases are a tedious thing. Sometimes a time value is recorded as a timestamp, at other times - probably in most cases - it is recorded as a date. Yet it can be useful to perform date-time queries using a representation of time distinct from what is recorded in the table. For example a database which records timestamps, but I want to look-up records by date.
To this end PostgreSQL supports indexing a table by a cast of a field.
published by whitemice on Fri, 08/30/2019 - 15:36
The assignment of print queues to device URIs can be listed from a CUPS server using the "-v" option.
The following authenticates to the CUPS server cups.example.com as user adam and lists the queue and device URI relationships.
published by whitemice on Fri, 08/30/2019 - 15:29
Listing completed jobs
By default the lpstat command lists the queued/pending jobs on a print queue. However the completed jobs still present on the server can be listed using the "-W completed" option.
For example, to list the completed jobs on the local print server for the queue named "examplep":
published by whitemice on Fri, 08/30/2019 - 15:11
Create A Print Queue
[root@host ~]# /usr/sbin/lpadmin -U adam -h cups.example.com:631 -p examplelm1 -E \
-m "foomatic:HP-LaserJet-laserjet.ppd" -D "Example Pick Ticket Printer"\
-L "Grand Rapids" -E -v lpd://printer.example.com/lp
This will create a queue named examplelm1 on the host cups.example.com as user adam.
published by whitemice on Thu, 07/25/2019 - 11:29
Uh oh, Active Directory password is going to expire!
Ugh, do I need to log into a Windows workstation to change by password?
Nope, it is as easy as:
published by whitemice on Fri, 05/24/2019 - 16:09
Added a cron job to a service account's crontab using the standard crontab -e -u ogo command. This server has been chugging away for more than a year, with lots of stuff running within he service account - but nothing via cron.
Subsequently the cron jobs didn't run. :( The error logged in /var/log/cron was:
published by whitemice on Thu, 04/18/2019 - 14:30
This is a query to report the number of rows and the estimated size of all the tables in a MySQL database:
SELECT
table_name,
table_rows,
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS mb_size
FROM information_schema.tables
WHERE table_schema = 'maindb;
Results look like:
published by whitemice on Mon, 04/08/2019 - 16:10
The current database locks in an Informix engine are easily enumerated from the sysmaster database.
SELECT
TRIM(s.username) AS user,
TRIM(l.dbsname) AS database,
TRIM(l.tabname) AS table,
TRIM(l.type) AS type,
s.sid AS session,
l.rowidlk AS rowid
FROM sysmaster:syslocks l
INNER JOIN sysmaster:syssessions s ON (s.sid = l.owner)
WHERE l.dbsname NOT IN('sysmaster')
ORDER BY 1;
The results are pretty straight forward:
published by whitemice on Sat, 09/08/2018 - 16:05
Exporting records from an Informix table is simple using the UNLOAD TO command. This creates a delimited text file with a row for each record and the fields of the record delimited by the specified delimiter. Useful for data archive the files can easily be restored or processed with a Python script.
Pages