Forum › Forums › General › Software › apt-notifier, when run from cron doesnt show the upgradable packages [SOLVED]
- This topic has 22 replies, 5 voices, and was last updated Nov 21-8:36 pm by BobC.
-
AuthorPosts
-
July 7, 2021 at 10:37 am #62858Moderator
BobC
When updates are available, I click the icon in the tray and it pops up showing how many updates are available, but I wish it would provide a list of them.
Is there a configuration change I could make to get it to show the packages before going into the upgrade process?
I see that there are a couple of commands I could run to get a list. Both run quickly. It would be best to show the package, current and update versions and description, but either output format would be ok. Currently, I have to click the Upgrade box, and enter my password to get a list, and then I get the option to upgrade or not. I adjusted the commands to provide the desired fields:
aptitude -F "%p %v %V %d" search "~U" libuv1 1.24.1-1 1.24.1-1+deb10 asynchronous event notification library - runtime libraryapt list --upgradable --verbose libuv1/stable 1.24.1-1+deb10u1 amd64 [upgradable from: 1.24.1-1] asynchronous event notification library - runtime libraryThanks for any suggestions or ideas..
PS: I wonder if this is a configuration problem with my machine. I tried running it from another machine and it shows the list of new and upgradable packages. Here is the apt.conf that is in the tmp directory
$ cat apt.conf // Recommends are as of now still abused in many packages APT::Install-Recommends "0"; APT::Install-Suggests "0"; Dir "/tmp/apt-notifier.XnN9MC/"; Dir::State "/var/lib/apt/"; Dir::State::Lists "/var/lib/apt/lists/"; Dir::State::status "/var/lib/dpkg/status"; Dir::State::extended_states "/var/lib/apt/extended_states"; Dir::Cache "/var/cache/apt/"; Dir::Cache::Archives "/var/cache/apt/archives"; Dir::Cache::srcpkgcache "/var/cache/apt/srcpkgcache.bin"; Dir::Cache::pkgcache "/var/cache/apt/pkgcache.bin";- This topic was modified 1 year, 10 months ago by BobC.
- This topic was modified 1 year, 10 months ago by BobC.
- This topic was modified 1 year, 10 months ago by BobC.
Attachments:
July 7, 2021 at 2:59 pm #62866Memberfehlix
::When updates are available, I click the icon in the tray and it pops up showing how many updates are available, but I wish it would provide a list of them.
Is there a configuration change I could make to get it to show the packages before going into the upgrade process?
When updates are available, they would normally be listed within the shown yad-window.
The list shown is generated with such kind of command running as normal user:
apt-get -o Debug::NoLocking=true --trivial-only -V dist-upgrade 2>/dev/null
The actually used command has a bit more as it would also cater for any hold or marked packages within synaptic.
Another command sometimes helpful to see what would be done is a simulation with “-s”
sudo apt -s full-upgrade
~~~
fehlix- This reply was modified 1 year, 10 months ago by fehlix.
- This reply was modified 1 year, 10 months ago by fehlix.
July 7, 2021 at 4:56 pm #62870ModeratorBobC
::fehlix,
Thanks for the help. I can see the problem is my fault. I am running a script from my user id’s crontab to execute apt-notifier if there are any updates needed. I do that to save 60 mb of memory by avoiding running the python (and yes, I have no updater icon until it gets called – which is fine) unless there are updates needed. The 60 mb doesn’t matter on this PC, but it does matter on my old Pentium testing machines.
The crontab part of it works ok, and when it sees any packages that can be updated, it executes apt-notifier, but then the apt-notifier.py comes up in the window saying 0 to update, even when there are updates needed. If I tell it to go ahead and update, it does show the correct list after asking the password.
It must be something I did wrong in the way I called apt-notifier?
Things I tried that didn’t solve it so far:
/usr/bin/apt-notifier
/usr/bin/apt-notifier &
apt-notifier
apt-notifier &
bash -c /usr/bin/apt-notifier
bash -c /usr/bin/apt-notifier &I’m sorry, I thought I had it working originally.
Any ideas?
The relevant code from the script I’m calling from crontab is:
# see how many updates are needed updates=$(aptitude search "~U" | wc -l) anpid=$(ps aux | grep '[a]pt-notifier' | awk '{print $2}') # and check the output says 0... if [[ "$updates" -eq 0 ]]; then # no upgrade needed # if apt-notifier is running, it is wasting memory, so kill it if [[ ! -z $anpid ]] then # echo "kill it" kill $anpid fi else # upgrade needed # if apt-notifier is not running, start it so it appears in system tray if [[ -z $anpid ]] then # echo "start it" # start it bash -c apt-notifier fi fi exit 0July 7, 2021 at 5:13 pm #62871Memberfehlix
July 7, 2021 at 5:41 pm #62872ModeratorBobC
::Its all up to date except the 1 package…
$ apt-cache show apt-notifier
Package: apt-notifier
Version: 18.04.12
Architecture: all
Maintainer: Steve (Stevo) Pusser <maintainer@mepiscommunity.org>$ inxi -Fxz
System: Host: XPS15-7559 Kernel: 4.9.240-antix.1-amd64-smp x86_64 bits: 64 compiler: gcc v: 8.3.0 Desktop: IceWM 2.5.0
Distro: antiX-19.3_x64-full Manolis Glezos 15 October 2020 base: Debian GNU/Linux 10 (buster)
Machine: Type: Laptop System: Dell product: Inspiron 7559 v: 1.3.1 serial: <filter>
Mobo: Dell model: 0H0CC0 v: A00 serial: <filter> UEFI: Dell v: 1.3.1 date: 12/02/2018
Battery: ID-1: BAT0 charge: 53.8 Wh condition: 53.8/74.0 Wh (73%) model: SIMPLO Dell status: Full
CPU: Topology: Quad Core model: Intel Core i7-6700HQ bits: 64 type: MT MCP arch: Skylake-S rev: 3 L2 cache: 6144 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 41472
Speed: 900 MHz min/max: 800/3500 MHz Core speeds (MHz): 1: 900 2: 900 3: 899 4: 900 5: 900 6: 900 7: 900 8: 900July 7, 2021 at 6:05 pm #62873Memberfehlix
::Thanks. Actually I like the idea to only invoke apt-notifier, when it may be needed for doing the upgrade. … later …
July 7, 2021 at 8:39 pm #62875ModeratorBobC
::fehlix, Thanks for the replies. If you need a tester, I have multiple antiX and MX systems available.
In the meantime I temporarily added a pop up terminal display of the list to my screen before running apt-notifier to put the icon in the tray, etc. I suppose I could just run the upgrade from there, but its just a temporary solution. I do like the user friendly icon and configurable updater, but just can’t always afford the memory. I couldn’t use roxterm because it doesn’t allow for a -hold option, so I used xterm instead.
It still bothers me that I couldn’t figure out how to call apt-notifier correctly, but it just takes time and experience to learn I guess…
# see how many updates are needed updates=$(aptitude search "~U" | wc -l) anpid=$(ps aux | grep '[a]pt-notifier' | awk '{print $2}') # and check the output says 0... if [[ "$updates" -eq 0 ]]; then # no upgrade needed # if apt-notifier is running, it is wasting memory, so kill it if [[ ! -z $anpid ]] then # echo "kill it" kill $anpid fi else # upgrade needed # if apt-notifier is not running, start it so it appears in system tray if [[ -z $anpid ]] then # echo "start it" # start it xterm -title "NOTICE: Updates Available" -hold -display :0.0 -e apt-get -o Debug::NoLocking=true --trivial-only -V dist-upgrade & apt-notifier & fi fi exit 0- This reply was modified 1 year, 10 months ago by BobC.
Attachments:
July 7, 2021 at 11:56 pm #62882Memberfehlix
::To you original question. It might be something simple like adding a proper PATH into the script.
as crontab would only provide a minimum environment with a fairly reduced PATH parameter. So you might need to add something like export PATH=/usr/local/bin:/usr/bin:/usr/sbin
I’m not sure that’s the reason for not displaying the counts, but IIRC, apt-notifier uses some scripts located within /usr/local/bin which might not be available within the crontab environment.July 8, 2021 at 12:24 am #62883ModeratorBobC
July 8, 2021 at 2:19 am #62890ModeratorBobC
::Yes, you were correct that the environment is very different, and the path didn’t include many values normally set, and others are different.
I got the path changed, and I can see that it’s corrected, but correcting it and adding $HOME and $USER ($USER was referenced in apt-notifier) values didn’t resolve the issue.
The books I have don’t go into any of this, just using cron to run simple scripts.
I will change the title to my thread to be more specific. Things aren’t always what they appear to be initially.
What I have works well enough for now, so I’ll mark it solved, but it would be nice if it didn’t use the memory unless updates were available.
Thanks again for your help and patience.
- This reply was modified 1 year, 10 months ago by BobC.
July 8, 2021 at 5:57 am #62898ModeratorBobC
::fehlix,
Further digging and much testing eventually revealed that the difference, once past the cron troubles, was the limitations made by the “$TMP”apt.conf file which reduced the 1 update available shown down to 0. I made a special debug version of the apt-notifier.py program that runs it with and without the apt.conf limitations both ways just before the yad window, and outputs the results to text files for comparison. When I run the actual upgrade, I think the update will actually get installed.
I saved copies of all the files if you want me to put it into a zip file to send to you. I can’t really say if it will affect anyone but me, unless I change my setup to run the original without using the cron. I could do that to help you test if you want me to.
July 8, 2021 at 8:00 am #62899Memberfehlix
::fehlix,
I saved copies of all the files if you want me to put it into a zip file to send to you. I can’t really say if it will affect anyone but me, unless I change my setup to run the original without using the cron. I could do that to help you test if you want me to.Just attach the changed files to a post here, I’ll have a look. Also if you mind send the crontab and the script you are running, just in case…
Thanks.July 22, 2021 at 7:52 am #63406ModeratorBobC
::Fehix, I’m guessing you worked on the antiX implementation, so thanks from everyone for creating that. My little memory saving tweak here is needed for my memory strapped old 512 mb P III, but without your code, there would be nothing for me to run automatically.
I’ve played with it a bit, and the solution I settled on was to pop up a YAD window with details and offering to run the standard antiX apt-notifier program if I found something needing done, so it can utilize all your built in features, and if nothing to do, it just uses minimal resources via cron waiting to check again 8 hours (configurable, added to your rc file) later, saving 60 mb of memory until there are updates available, dropping to 30 mb of savings once waiting at the YAD box until updates are processed or it’s cancelled.
I first run my check when ~/.desktop-session/startup runs, and popup a “here’s what needs updated, update or cancel” YAD box if there is anything needing done, then, after the initial check, I add the check to my crontab to run every configured interval (default 8 hours) from then on. It will bug me a few times a day max that way if I am holding off updating something, so I don’t forget about it, but it doesn’t use any memory till the next check if I hit cancel. If I tell it to Update, then it changes the cron interval to 10 minutes and runs your apt-notifier. When my script run by the cron sees the updates no longer needed, it kills apt-notifier and resets the cron check back to the configured interval.
I considered building the functionality into the apt-notifier code, where it would be combined with the script called by cron, but then I would need to maintain modified antiX code, so I kept it separate. It would be nicer code if built in, I’m sure. If anyone is interested I can post a zip file of the code.
July 26, 2021 at 2:26 pm #63629Member
blur13
July 27, 2021 at 1:54 am #63704ModeratorBobC
::Ok, I made a .zip file. There are no changes to any antiX programs, but its setup to be run from ~/bin, which needs to be in the path. As the instructions below show, you also need add a few lines of code to your ~/.desktop-session/startup to make and start the cron entry.
The files suffixed with .bobc are to show you what those files look like on my system, but all of the things in them are setup for my system.
Here are the instructions from $HOME/bin/aptitude-notifier-check.sh
#!/bin/bash # aptitude-notifier-check.sh - runs from cron - aptitude search to check if upgrade needed # if no updates available and apt-notifier is running, then kill it # if updates available, and apt-notifier isn't running, then start it # Once no updates are available, the next time cron runs this script, it kills apt-notifier to # save approx 60 mb of memory, and restarts it the next time it sees updates are available # this script needs to be in the path (suggest: $HOME/bin which needs to be created and added to default path) and needs to be executable # requires aptitude, apt-notifier and cron (cron is included in std antiX-full) # to install those: #sudo apt-update #sudo install aptitude apt-notifier # remove leading ### and add ### code to ~/.desktop-session/startup after installing apt-notifier #### Uncomment after installing apt-notifier ####apt-notifier & #### Requires apt-notifier be installed, check for updates every 6 hrs via cron saves memory ###CronCheckHours=6 ###if [ -f ~/.config/apt-notifierrc ]; then ### grep -q -e ^CronCheckHours= ~/.config/apt-notifierrc ### if [ "$?" -eq 0 ]; then ### CronCheckHours=$(grep ^CronCheckHours ~/.config/apt-notifierrc | cut -f2 -d=) ### else ### # ### #if file exists but a CronCheckHours line not present, ### #set it to default value ### sed -i '/^CronCheckHours/d' ~/.config/apt-notifierrc ### echo -e 'CronCheckHours=$CronCheckHours\n'>> ~/.config/apt-notifierrc ### fi ###fi ### ###. $HOME/bin/aptitude-notifier-check.sh & ###crontemp=$(mktemp) && crontab -l | grep -v "aptitude-notifier-check.sh" >$crontemp && \ ### crontab -r && echo "* */$CronCheckHours * * * env DISPLAY=:0.0 $HOME/bin/aptitude-notifier-check.sh" >>$crontemp && cat $crontemp | crontab - && rm -f $crontemp # you can verify it is in crontab from a terminal session if desired #$ crontab -l #* /6 * * * env DISPLAY=:0.0 $HOME/bin/aptitude-notifier-check.shAttachments:
-
AuthorPosts
- You must be logged in to reply to this topic.

