Hot answers tagged

11 votes

Robust way to resolve a DNS address in a script (IPv4 (A) and IPv6 (AAAA))?

I'm unsure if you want to actually query nameservers or rather rely on your system's name resolution: $ getent ahosts one.one.one.one. | awk '{ print $1 }' | sort -u 1.0.0.1 1.1.1.1 2606:4700:4700::...
  • 9,413
7 votes

Robust way to resolve a DNS address in a script (IPv4 (A) and IPv6 (AAAA))?

getent ahosts[v4|v6] and generally anything that uses getaddrinfo() is the right answer, as it will use the same name resolution mechanisms (DNS, mDNS, NetBIOS, NIS, LDAP…) as the rest of the system, ...
  • 8,727
7 votes

Robust way to resolve a DNS address in a script (IPv4 (A) and IPv6 (AAAA))?

You are on the right track with dig. You can suppress that particular cookie related error (per the man page). Below, I am also choosing to redirect all errors to /dev/null just in case, as you wanted ...
  • 196
1 vote

How to monitor scripts executed via cron and perform action on elapsed times?

I've moved most of my cron jobs into systemd timer units. This makes the process of managing them much easier; I don't need to use ps to look up processes to see what to PID to kill. E.g, instead of: ...
  • 41.3k
1 vote

Initramfs - Set hostname from custom initrd script

Answering the question in the title (I came here searching for this): The hostname for the currently running kernel (or namespace) can be set via: echo "machine1" > /proc/sys/kernel/...

Only top scored, non community-wiki answers of a minimum length are eligible