Automate Debian Organization Updates Using Crontab
Updating a Debian organization is every bit slowly every bit executing the next command every bit root
:
# apt-get update && apt-get upgrade
If y'all convey a sudo
account, live on the command similar this:
$ sudo apt-get update && sudo apt-get upgrade
Instead of running the command interactively, y'all tin displace automate the manual update procedure yesteryear running a cron
job. Below, I assume y'all login every bit root.
Run the next command to practise or edit your cron
jobs. Note that the default text editor is opened automatically for y'all to motion into the cron
jobs.
# crontab -e
As an example, I volition schedule the update to hand off daily at 2am. I entered the next describe every bit my outset (failed) attempt.
00 02 * * * apt-get update 2>&1 && apt-get -y upgrade 2>&1
A typical upgrade normally prompts y'all to confirm a transaction earlier it is executed. Because the cron
upgrade is non-interactive, I specify the -y
parameter to nation apt-get
to assume yep for all prompts.
At 2am, the to a higher house command executed, together with failed amongst the next errors:
debconf: unable to initialize frontend: Dialog debconf: (TERM is non set, together with then the dialog frontend is non usable.) debconf: falling dorsum to frontend: Readline debconf: unable to initialize frontend: Readline debconf: (This frontend requires a controlling tty.) debconf: falling dorsum to frontend: Teletype dpkg-preconfigure:unable to re-open stdin: Fetched 49.5 MB inwards 17s (2,840 kB/s) dpkg: warning: 'ldconfig' non establish inwards PATH or non executable dpkg: warning: 'start-stop-daemon' non establish inwards PATH or non executable dpkg: error: two expected programs non establish inwards PATH or non executable Note: root's PATH should normally incorporate /usr/local/sbin, /usr/sbin together with /sbin E: Sub-process /usr/bin/dpkg returned an fault code (2)
There were two problems. First, a front-end was expected, exactly at that topographic point was none. Second, the PATH
for locating commands was non ready correctly.
To right the problems, re-run crontab -e
, together with insert the next lines to properly ready the run-time environment.
DEBIAN_FRONTEND=noninteractive PATH=/usr/sbin:/usr/bin:/sbin:/bin 00 02 * * * apt-get update 2>&1 && apt-get -y upgrade 2>&1
Automating the organization update procedure saves y'all time, together with proceed your organization to a greater extent than up-to-date every bit a protection against potential cyber attacks. If y'all are interested inwards Debian organization administration, delight come across What to practise later spinning upward a Debian VPS.
0 Response to "Automate Debian Organization Updates Using Crontab"
Post a Comment