I have the following code in my script:
mapfile results < <(mysql --batch -u $DB_USERNAME -p$DB_PASSWORD $DB_DATABASE < query.sql)
and it works fine if running from command line. But if running from /var/spool/cron/root
then $results
variable contains nothing.
Why and how to fix?
~/.my.cnf
, readable only by you) rather than put the password on the command line....any process running on the system can scan the process table (e.g. runps
or trawl through/proc/*/cmdline
) and extract the password. – cas Oct 18 '21 at 03:45