why terminal output can't be saved to file when there's core dumped - coredump

I'm running an executable and trying to save terminal output to a file:
# ll
total 132
-rw-r--r--. 1 root root 496 Jun 14 11:41 mpx-debug.h
-rw-r--r--. 1 root root 12775 Jun 14 11:41 mpx-dig.c
-rw-r--r--. 1 root root 3526 Jun 14 11:41 mpx-hw.h
-rwxr-xr-x. 1 root root 65176 Jun 14 14:28 mpx-mini-test
-rw-r--r--. 1 root root 40480 Jun 14 11:41 mpx-mini-test.c
-rw-r--r--. 1 root root 205 Jun 14 11:41 mpx-mm.h
# ./mpx-mini-test
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x1f
XSAVE OS supported state mask: 0x1f
BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
no MPX support
Aborted (core dumped)
#
# ./mpx-mini-test | tee -a mpx-mini-test.log
#
# cat mpx-mini-test.log
#
As you can see, there're some prints in terminal without "| tee -a **.log".
But with "| tee -a **.log", nothing is saved to file.
I suspect it has something to do with the "Abort (core dumped)", did some googling but can't figure out exactly why. Is there anyone knows why? And how could I save all terminal outputs(including the "Abort (core dumped)") to file? Thanks in advance.

Related

How to create a symlink to point to latest rotating log file

I've my application log file which keeps rotating and it has a pattern like below
postgresql-yyyy-mm-dd_hhmmss.log
-rw-------. 1 root root 331 Jun 1 22:04 postgresql-2022-06-01_220333.log.gz
-rw-------. 1 root root 417 Jun 1 22:04 postgresql-2022-06-01_220430.log.gz
-rw-------. 1 root root 289 Jun 2 19:28 postgresql-2022-06-02_000000.log.gz
-rw-------. 1 root root 26802 Jun 2 19:50 postgresql-2022-06-02_192809.log.gz
-rw-------. 1 root root 8440 Jun 2 23:57 postgresql-2022-06-02_195044.log.gz
-rw-------. 1 root root 15016 Jun 3 11:22 postgresql-2022-06-03_000000.log.gz
-rw-------. 1 root root 291 Jun 3 11:24 postgresql-2022-06-03_112405.log.gz
-rw-------. 1 root root 336 Jun 3 11:25 postgresql-2022-06-03_112553.log.gz
-rw-------. 1 root root 397 Jun 3 11:27 postgresql-2022-06-03_112714.log.gz
-rw-------. 1 root root 358 Jun 3 11:29 postgresql-2022-06-03_112901.log.gz
-rw-------. 1 root root 493 Jun 3 11:30 postgresql-2022-06-03_113031.log.gz
-rw-------. 1 root root 418 Jun 3 11:34 postgresql-2022-06-03_113354.log.gz
-rw-------. 1 root root 419 Jun 3 11:39 postgresql-2022-06-03_113920.log.gz
-rw-------. 1 root root 416 Jun 3 11:44 postgresql-2022-06-03_114437.log.gz
-rw-------. 1 root root 417 Jun 3 11:49 postgresql-2022-06-03_114943.log.gz
-rw-------. 1 root root 419 Jun 3 11:55 postgresql-2022-06-03_115530.log.gz
-rw-------. 1 root root 16961 Jun 3 23:56 postgresql-2022-06-03_120047.log.gz
-rw-------. 1 root root 35470 Jun 4 23:56 postgresql-2022-06-04_000000.log.gz
-rw-------. 1 root root 406059 Jun 5 17:56 postgresql-2022-06-05_000000.log
I want to run a small script(unix/linux) such that it creates a symlink in this folder which always points to the latest(current) logfile automatically for e.g
postgres.LOG -> postgresql-2022-06-05_000000.log
This way I don't have to ls and find out what is the current log file before opening, instead just open postgres.LOG.
All rotated logfiles seem gzipped so the glob postgresql-*.log will expand to the logfile of interest:
ln -sf postgresql-*.log postgres.LOG
If you want the symbolic link to be changed automatically each time a new log file is created you need inotify.
Something like this
#! /bin/bash
log_dir=/your/log/dir
inotifywait -m -e create "$log_dir" | while read -r _dir event file
do
if [[ ! -h "$log_dir/$file" && "$file" =~ \.log$ ]]
then
ln -sf "$log_dir/$file" "$log_dir/postgres.LOG"
fi
done
The format of the filename makes sure that the newest file sorts as last using ls. So this should work:
ln -sf $(ls postgresql-*.log | tail -1) postgres.LOG

CentOs 7, "Tesseract couldn't load any languages!" however: "List of available languages (2): eng, spa"

this is CentOs 7
when I run tesseract --list-langs
[root#cia tessdata]# tesseract --list-langs
Error opening data file /usr/local/share/tessdata/eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
List of available languages (2):
eng
spa
[root#cia tessdata]#
however when I run
[root#cia tessdata]# ls -l /usr/local/share/tessdata/
total 328
drwxr-xr-x. 2 root root 4096 Nov 17 23:28 configs
-rw-r--r--. 1 root root 164228 Nov 18 06:11 eng.traineddata
-rw-r--r--. 1 root root 572 Nov 17 23:28 pdf.ttf
-rw-r--r--. 1 root root 157745 Nov 18 06:11 spa.traineddata
drwxr-xr-x. 2 root root 98 Nov 17 23:28 tessconfigs
[root#cia tessdata]#
I get eng.traineddata and spa.traineddata in this form:
cd /usr/local/share/tessdata
wget https://github.com/tesseract-ocr/tessdata/blob/main/eng.traineddata
wget https://github.com/tesseract-ocr/tessdata/blob/main/spa.traineddata
:::::::::::::::::::::::::::::::::::::::::::
allways I install languages with:
wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata
wget https://github.com/tesseract-ocr/tessdata/raw/master/spa.traineddata
then allways tesseract work fine, but now this return 404
how I can fix?

buildroot: No rootfs in rootfs.iso9660 image file

I am trying to build my own USB Bootable Linux.
As far as I have understood the buildroot documentation, buildroot should give me ready-for-use images.
My output folder contains the following images:
build#build:~/buildroot_usb/output/images$ ls * -lh
-rw-r--r-- 1 root root 45M Sep 19 18:26 bzImage
-rw-r--r-- 1 root root 102M Sep 19 18:25 rootfs.cpio
-rw-r--r-- 1 root root 512M Sep 19 18:25 rootfs.ext2
lrwxrwxrwx 1 root root 11 Sep 19 18:25 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root 46M Sep 19 18:26 rootfs.iso9660
-rw-r--r-- 1 root root 111M Sep 19 18:26 rootfs.tar
-rw-r--r-- 1 root root 37M Sep 19 18:26 rootfs.tar.gz
syslinux:
insgesamt 164K
-rwxr-xr-x 1 root root 36K Sep 19 17:42 isolinux.bin
-rwxr-xr-x 1 root root 440 Sep 19 17:42 mbr.bin
-rwxr-xr-x 1 root root 124K Sep 19 17:42 syslinux.efi
build#build:~/buildroot_usb/output/images$
The rootfs.iso9600 image should be a Bootable ISO image. But the size of the file shows that the whole root file system is missing. it's only the kernel and the bootloader inside. (i checked that).
Config:
You have enabled to have the root filesystem as an initramfs inside the kernel image, so it gets compressed. If you look at your bzImage file (the kernel image), it's 45 MB, so it's definitely the kernel + the compressed root filesystem. Your ISO image is 46 MB, so it's basically just the kernel image + the bootloader, so it's all good.
Compare that to the size of the compressed rootfs tarball (rootfs.tar.gz), which is 37 MB in size. It all matches pretty well.
So, your 46 MB ISO image definitely contains the root filesystem, compressed as an initramfs inside the kernel image.

Has anyone tried using the bitbake-env utility lately?

Has anyone tried using the bitbake-env utility lately?
I do not see it installed:
[user#localhost build]$ which bitbake
~/YOCTO/oe_core_embedded/poky/bitbake/bin/bitbake
[user#localhost build]$ which bitbake-env
/usr/bin/which: no bitbake-env in (/home/user/YOCTO/oe_core_embedded/poky/scripts:/home/user/YOCTO/oe_core_embedded/poky/bitbake/bin:/usr/libexec/python2-sphinx:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/user/.local/bin:/home/user/bin)
[user#localhost build]$
As well I do not see it in the bitbake command listing:
[user#localhost poky]$ cd bitbake/bin
[user#localhost bin]$ ls -al
total 100
drwxrwxr-x. 2 user user 4096 Oct 18 12:49 .
drwxrwxr-x. 6 user user 4096 Oct 18 12:49 ..
-rwxrwxr-x. 1 user user 2072 Nov 18 11:51 bitbake
-rwxrwxr-x. 1 user user 7228 Oct 18 12:49 bitbake-diffsigs
-rwxrwxr-x. 1 user user 2894 Oct 18 12:49 bitbake-dumpsig
-rwxrwxr-x. 1 user user 4069 Oct 18 12:49 bitbake-layers
-rwxrwxr-x. 1 user user 2109 Oct 18 12:49 bitbake-prserv
-rwxrwxr-x. 1 user user 2128 Oct 18 12:49 bitbake-selftest
-rwxrwxr-x. 1 user user 17866 Oct 18 12:49 bitbake-worker
-rwxrwxr-x. 1 user user 13951 Oct 18 12:49 bitdoc
-rwxrwxr-x. 1 user user 5813 Oct 18 12:49 git-make-shallow
-rwxrwxr-x. 1 user user 8805 Oct 18 12:49 toaster
-rwxrwxr-x. 1 user user 4177 Oct 18 12:49 toaster-eventreplay
[user#localhost bin]$
It still exists/is listed in https://elinux.org/Bitbake_Cheat_Sheet from July 2016.
bitbake-env is a third party utility, and not actually a part of the OpenEmbedded Core hence why you will not see it unless you specifically install it. It is actually an 'improved' version of the bitbake -e flag for bitbake.
bash-4.3$ bitbake --help
Usage: bitbake [options] [recipename/target recipe:do_task ...]
Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
will provide the layer, BBFILES and other configuration information.
Options:
...
-e, --environment Show the global or per-recipe environment complete
with information about where variables were
set/changed.

How to create mongodb package to install with apt-get on Ubuntu?

I'm building MongoDb from the sources (https://github.com/mongodb/mongo.git) and now want to package it as a .deb package such that I can install it on other Ubuntu machines using apt-get. Building it on Ubuntu 12.04.4 x64 is not the problem, but I cannot figure out how to create a .deb package from it.
The 'debian' directory in the checkout from git contain .rules and .control files but what command(s) must I invoke to create a package for the mongodb-enterprise version? Since all control files seem to be present I'd assume it's a matter of just running a command, but I cannot find it in the documentation or on the mongodb website. Also read the documenatation that TeTeT mentioned in the comments, but then I'd need to start form scratch to create the package and all that is needed already seems to be part of the 'debian' directory... just can figure out how to use it to build the package.
I did try using the dh_builddeb command, but that reported that the .control files is not a debian format archive.
The 'debian' directory contains the following files:
root#buildmongo:/mongobuild/mongo# ls -l debian/
total 424
-rw-r--r-- 1 root root 4001 Jul 25 16:12 bsondump.1
-rw-r--r-- 1 root root 5077 Jul 25 16:12 changelog
-rw-r--r-- 1 root root 2 Jul 25 16:12 compat
-rw-r--r-- 1 root root 483 Jul 25 16:12 copyright
-rw-r--r-- 1 root root 33 Jul 25 16:12 dirs
-rw-r--r-- 1 root root 39 Jul 25 16:12 files
-rw-r--r-- 1 root root 8216 Jul 25 16:12 init.d
-rw-r--r-- 1 root root 891 Jul 25 16:12 lintian-overrides
-rw-r--r-- 1 root root 16595 Jul 25 16:12 mongo.1
-rw-r--r-- 1 root root 39099 Jul 25 16:12 mongod.1
-rw-r--r-- 1 root root 1693 Jul 25 16:12 mongod.conf
-rw-r--r-- 1 root root 1676 Jul 25 16:12 mongod.upstart
-rw-r--r-- 1 root root 154 Jul 25 16:12 mongodb-enterprise-server.docs
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-enterprise-server.postinst
-rw-r--r-- 1 root root 154 Jul 25 16:12 mongodb-enterprise-unstable-server.docs
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-enterprise-unstable-server.postinst
-rw-r--r-- 1 root root 14760 Jul 25 16:12 mongodb-enterprise-unstable.control
-rw-r--r-- 1 root root 4524 Jul 25 16:12 mongodb-enterprise-unstable.rules
-rw-r--r-- 1 root root 14845 Jul 25 16:12 mongodb-enterprise.control
-rw-r--r-- 1 root root 4226 Jul 25 16:12 mongodb-enterprise.rules
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-org-server.postinst
-rw-r--r-- 1 root root 1441 Jul 25 16:12 mongodb-org-unstable-server.postinst
-rw-r--r-- 1 root root 14704 Jul 25 16:12 mongodb-org-unstable.control
-rw-r--r-- 1 root root 4345 Jul 25 16:12 mongodb-org-unstable.rules
-rw-r--r-- 1 root root 14839 Jul 25 16:12 mongodb-org.control
-rw-r--r-- 1 root root 4049 Jul 25 16:12 mongodb-org.rules
-rw-r--r-- 1 root root 16840 Jul 25 16:12 mongodump.1
-rw-r--r-- 1 root root 19099 Jul 25 16:12 mongoexport.1
-rw-r--r-- 1 root root 14153 Jul 25 16:12 mongofiles.1
-rw-r--r-- 1 root root 16065 Jul 25 16:12 mongoimport.1
-rw-r--r-- 1 root root 13347 Jul 25 16:12 mongooplog.1
-rw-r--r-- 1 root root 5825 Jul 25 16:12 mongoperf.1
-rw-r--r-- 1 root root 16644 Jul 25 16:12 mongorestore.1
-rw-r--r-- 1 root root 23535 Jul 25 16:12 mongos.1
-rw-r--r-- 1 root root 5388 Jul 25 16:12 mongosniff.1
-rw-r--r-- 1 root root 15941 Jul 25 16:12 mongostat.1
-rw-r--r-- 1 root root 12415 Jul 25 16:12 mongotop.1
-rw-r--r-- 1 root root 932 Jul 25 16:12 postrm
-rw-r--r-- 1 root root 692 Jul 25 16:12 preinst
-rw-r--r-- 1 root root 894 Jul 25 16:12 prerm
-rw-r--r-- 1 root root 329 Jul 25 16:12 watch
(I'm building MongoDb because I need SSL support and do not need a support contract with Mongo. If I understand it correct you can only use the enterprise version (supports SSL) downloaded from the mongodb site if you signup for a support contract. )
Regards,
Gero
Upstream packaging is rarely better than maintainer's one so I would get source package from Debian:
apt-get install devscripts
dget -ux http://http.debian.net/debian/pool/main/m/mongodb/mongodb_2.4.10-2.dsc
cd mongodb-2.4.10/
## install Build-Depends (extracted from "debian/control"):
sudo apt-get install debhelper dh-systemd libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libgoogle-perftools-dev libpcap-dev libpcre3-dev libreadline-dev libsnappy-dev libstemmer-dev libssl-dev libv8-dev python-pymongo scons
debuild -uc -b
I'm with Debian so I did not test the above procedure on Ubuntu (which I don't recommend).
If package did not build (due to lack of build dependencies etc.) then you may choose a different suite from the following page
https://packages.debian.org/search?searchon=sourcenames&keywords=mongodb
and try to fetch an older DSC file.
Good luck.