aws s3 ls s3://some_bucket/ --recursive
Author: rdircio
aws s3 list files according to their timestamp using bash
Search on a given date
aws s3api list-objects-v2 --bucket BUCKET_NAME --query 'Contents[?contains(LastModified, `YYYY-MM-DD`)].Key'
Search from a certain date to today
aws s3api list-objects-v2 --bucket BUCKET_NAME --query 'Contents[?LastModified>=`YYYY-MM-DD`].Key'
Install qemu guest tools for OLVM
yum -y install qemu-guest-agent ; systemctl enable --now qemu-guest-agent
x2go troubleshooting
x2go session database in the server is at /var/lib/x2go/x2go_sessions
You can reset it by running: x2godbadmin –create
you can query it by doing sqlite3 /var/lib/x2go/x2go_sessions
lun4194304 has a LUN larger than allowed by the host adapter
echo "options lpfc lpfc_nodev_tmo=10 lpfc_lun_queue_depth=32 lpfc_max_luns=2048" > /etc/modprobe.d/lpfc.conf
dracut -f
reboot
MacPorts clean port, because of checksum failure
I had some issues with checksums failing after a port downloading, so you can clean the port this way:
$ sudo port selfupdate $ sudo port clean --dist <portname> $ sudo port install <portname>
If you suspect you have packages with linking errors:
$ sudo port rev-upgrade
$ sudo port selfupdate
$ sudo port upgrade outdated
Solaris 11 sendmail relay config
cd /etc/mail/cf/cf
vi sendmail.mc (add SMARTHOST)
define(‘SMART_HOST’.’the smart host fqdn’)
/usr/ccs/bin/m4 ../m4/cf.m4 sendmail.mc > sendmail.cf
mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf_ORIG
cp /etc/mail/cf/cf/sendmail.cf /etc/mail/sendmail.cf
svcadm restart smtp:sendmail
Mysql trigger
If you want to trigger an action to another table you can create a trigger:
CREATE TRIGGER `update_menus` AFTER INSERT ON `usuarios` FOR EACH ROW insert into sys_user_roles set sys_roles_id=(select sys_roles_id from sys_roles where roles_name=NEW.tipo),user_id=NEW.user_id
CREATE TRIGGER `update_totals_after_delete` AFTER DELETE ON `pedidos_detalle`
FOR EACH ROW
update pedidos set subtotal = (select sum(importe) from pedidos_detalle where folio=OLD.folio)
where folio=OLD.folio
CREATE TRIGGER `update_totals_after_insert` AFTER INSERT ON `pedidos_detalle`
FOR EACH ROW
update pedidos set subtotal = (select sum(importe) from pedidos_detalle where folio=NEW.folio)
where folio=NEW.folio
mysql generated columns (same table)
This is to add a column in a table with calculated values from the same table.
ALTER TABLE pedidos add column impuesto float generated always as (subtotal*.16) VIRTUAL;
ALTER TABLE pedidos add column total float generated always as (subtotal*1.16) VIRTUAL;
ALTER TABLE pedidos add column flete float generated always as (case when total < 6000 then 1000 else 0 end) virtual
mysql add foreign key for delete cascade
This one adds a constraint to the orderdetails table such as if the order is deleted, its details get deleted too
ALTER TABLE pedidos_detalle add constraint foreign key(folio) references pedidos(folio) on delete cascade