Page 1 of 1

Examples to make "at" work

Posted: Mon Dec 25, 2023 1:36 pm
by Jakob77
In order to be able to run a program at a specific time in the future I have installed "at" with this command:

Code: Select all

sudo apt install at
The list of jobs in line can be seen with the command:

Code: Select all

at -l
Job 18 can be removed with the command:

Code: Select all

atrm 18


Output from "ls -l" can be sent to a file at a specific time:

Code: Select all

echo "ls -l > at-testfile.txt" | at 18:25


And the same without the email function:

Code: Select all

echo "ls -l > at-testfile.txt" | at -M 18:25



But a similar syntax for starting the vlc player or for that matter featherpad won't work:

Code: Select all

echo "vlc" | at -M 18:25

The job is listed, and it looks like it is executed but nothing happens.


How can I make it work.?



Thank you in advance.


Code: Select all

System:
  Kernel: 6.1.0-16-amd64 [6.1.67-1] arch: x86_64 bits: 64 compiler: gcc v: 12.2.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1.0-16-amd64 root=UUID=<filter> ro quiet splash
  Desktop: Xfce v: 4.18.1 tk: Gtk v: 3.24.36 info: xfce4-panel wm: xfwm v: 4.18.0 vt: 7
    dm: LightDM v: 1.26.0 Distro: MX-23.1_x64 Libretto October 15  2023 base: Debian GNU/Linux 12
    (bookworm)
Machine:
  Type: Laptop System: Dell product: Latitude E7240 v: 00 serial: <superuser required> Chassis:
    type: 9 serial: <superuser required>
  Mobo: Dell model: 08YF01 v: A00 serial: <superuser required> BIOS: Dell v: A29 date: 06/13/2019
Battery:
  ID-1: BAT0 charge: 37.7 Wh (100.0%) condition: 37.7/45.1 Wh (83.5%) volts: 8.4 min: 7.4
    model: SMP DELL KWFFN33 type: Li-ion serial: <filter> status: full
CPU:
  Info: model: Intel Core i5-4310U bits: 64 type: MT MCP arch: Haswell gen: core 4 level: v3
    note: check built: 2013-15 process: Intel 22nm family: 6 model-id: 0x45 (69) stepping: 1
    microcode: 0x26
  Topology: cpus: 1x cores: 2 tpc: 2 threads: 4 smt: enabled cache: L1: 128 KiB
    desc: d-2x32 KiB; i-2x32 KiB L2: 512 KiB desc: 2x256 KiB L3: 3 MiB desc: 1x3 MiB
  Speed (MHz): avg: 1210 high: 1260 min/max: 800/3000 scaling: driver: intel_cpufreq
    governor: ondemand cores: 1: 1187 2: 1232 3: 1161 4: 1260 bogomips: 20753
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: gather_data_sampling status: Not affected
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data status: Unknown: No mitigations
  Type: retbleed status: Not affected
  Type: spec_rstack_overflow status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB
    filling, PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel Haswell-ULT Integrated Graphics vendor: Dell driver: i915 v: kernel arch: Gen-7.5
    process: Intel 22nm built: 2013 ports: active: DP-2 off: eDP-1 empty: DP-1, DP-3, DP-4,
    HDMI-A-1, HDMI-A-2 bus-ID: 00:02.0 chip-ID: 8086:0a16 class-ID: 0300
  Display: x11 server: X.Org v: 1.21.1.7 compositor: xfwm v: 4.18.0 driver: X:
    loaded: modesetting unloaded: fbdev,vesa dri: crocus gpu: i915 display-ID: :0.0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x286mm (20.00x11.26") s-diag: 583mm (22.95")
  Monitor-1: DP-2 mapped: DP-1-1 pos: primary model: Dell U2713HM serial: <filter> built: 2013
    res: 1920x1080 hz: 60 dpi: 82 gamma: 1.2 size: 597x336mm (23.5x13.23") diag: 685mm (27")
    ratio: 16:9 modes: max: 2560x1440 min: 720x400
  Monitor-2: eDP-1 note: disabled model: BOE Display 0x05da built: 2013 res: 1920x1080 dpi: 125
    gamma: 1.2 size: 277x156mm (10.91x6.14") diag: 318mm (12.5") ratio: 16:9 modes: 1366x768
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: Mesa Intel HD Graphics 4400 (HSW GT2)
    direct-render: Yes
Audio:
  Device-1: Intel Haswell-ULT HD Audio vendor: Dell driver: snd_hda_intel v: kernel bus-ID: 00:03.0
    chip-ID: 8086:0a0c class-ID: 0403
  Device-2: Intel 8 Series HD Audio vendor: Dell 8 driver: snd_hda_intel v: kernel
    bus-ID: 00:1b.0 chip-ID: 8086:9c20 class-ID: 0403
  API: ALSA v: k6.1.0-16-amd64 status: kernel-api tools: alsamixer,amixer
  Server-1: PipeWire v: 1.0.0 status: active with: 1: pipewire-pulse status: active
    2: wireplumber status: active 3: pipewire-alsa type: plugin 4: pw-jack type: plugin
    tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Intel Ethernet I218-LM vendor: Dell driver: e1000e v: kernel port: f080 bus-ID: 00:19.0
    chip-ID: 8086:155a class-ID: 0200
  IF: eth0 state: down mac: <filter>
  Device-2: Intel Wireless 7260 driver: iwlwifi v: kernel modules: wl pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 bus-ID: 02:00.0 chip-ID: 8086:08b1 class-ID: 0280
  IF: wlan0 state: up mac: <filter>
Bluetooth:
  Device-1: Intel Bluetooth wireless interface type: USB driver: btusb v: 0.8 bus-ID: 1-1.3:3
    chip-ID: 8087:07dc class-ID: e001
  Report: hciconfig ID: hci0 rfk-id: 5 state: up address: <filter> bt-v: 2.1 lmp-v: 4.0
    sub-v: 500 hci-v: 4.0 rev: 500
  Info: acl-mtu: 1021:5 sco-mtu: 96:5 link-policy: rswitch hold sniff
    link-mode: peripheral accept service-classes: rendering, capturing, audio, telephony
RAID:
  Hardware-1: Intel 82801 Mobile SATA Controller [RAID mode] driver: ahci v: 3.0 port: f060
    bus-ID: 00:1f.2 chip-ID: 8086:282a rev: N/A class-ID: 0104
Drives:
  Local Storage: total: 119.24 GiB used: 24.02 GiB (20.1%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: LITE-ON IT model: LMT-128L9M-11 MSATA 128GB
    size: 119.24 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s type: SSD
    serial: <filter> rev: 10B scheme: MBR
Partition:
  ID-1: / raw-size: 119.24 GiB size: 116.81 GiB (97.96%) used: 24.02 GiB (20.6%) fs: ext4
    dev: /dev/sda1 maj-min: 8:1
Swap:
  Kernel: swappiness: 15 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: file size: 3 GiB used: 0 KiB (0.0%) priority: -2 file: /swap/swap
Sensors:
  System Temperatures: cpu: 58.0 C mobo: 45.0 C sodimm: SODIMM C
  Fan Speeds (RPM): cpu: 3971
Repos:
  Packages: pm: dpkg pkgs: 2122 libs: 1087 tools: apt,apt-get,aptitude,nala,synaptic pm: rpm
    pkgs: 0 pm: flatpak pkgs: 0
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/debian-stable-updates.list
    1: deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/debian.list
    1: deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
    2: deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
  Active apt repos in: /etc/apt/sources.list.d/mx.list
    1: deb http://mirrors.dotsrc.org/mx-packages/mx/repo/ bookworm main non-free
Info:
  Processes: 221 Uptime: 2h 35m wakeups: 2 Memory: 7.66 GiB used: 1.85 GiB (24.1%) Init: SysVinit
  v: 3.06 runlevel: 5 default: graphical tool: systemctl Compilers: gcc: 12.2.0 alt: 12
  Client: shell wrapper v: 5.2.15-release inxi: 3.3.26
Boot Mode: BIOS (legacy, CSM, MBR)

Re: Examples to make "at" work  [Solved]

Posted: Mon Dec 25, 2023 4:26 pm
by baldyeti
You may just need to export the DISPLAY variable, which apparently is not part of the environment associated with an "at" job, e.g

Code: Select all

echo "DISPLAY=:0 vlc myclip.mp4" | at 12:34

Re: Examples to make "at" work

Posted: Mon Dec 25, 2023 5:15 pm
by towwire
I can not help with that program but I can start programs at certain times in XFCE without that program.

You might want to check out the Xfce Timer panel plugin. For something on a schedule a contab job might be better.

I use a script to start the program and put it on a certain 'workspace'.
example here
https://forum.mxlinux.org/viewtopic.ph ... 4#p754214

I also use a script to start vlc with a url and record it for the time needed and then turn it off.
If you want to try my way say so and I'll help you.

Re: Examples to make "at" work

Posted: Mon Dec 25, 2023 5:34 pm
by Jakob77
baldyeti wrote: Mon Dec 25, 2023 4:26 pm You may just need to export the DISPLAY variable, which apparently is not part of the environment associated with an "at" job, e.g

Code: Select all

echo "DISPLAY=:0 vlc myclip.mp4" | at 12:34
Thank you very much. :thumbup:
There might be more to it later when I dig in deeper but for now this is completely solved.

Re: Examples to make "at" work

Posted: Mon Dec 25, 2023 5:36 pm
by Jakob77
towwire wrote: Mon Dec 25, 2023 5:15 pm I can not help with that program but I can start programs at certain times in XFCE without that program.

You might want to check out the Xfce Timer panel plugin. For something on a schedule a contab job might be better.

I use a script to start the program and put it on a certain 'workspace'.
example here
https://forum.mxlinux.org/viewtopic.ph ... 4#p754214

I also use a script to start vlc with a url and record it for the time needed and then turn it off.
If you want to try my way say so and I'll help you.
Thank you. That is very nice of you. I will if it comes to that. :thumbup:

Re: Examples to make "at" work

Posted: Fri Dec 29, 2023 7:52 pm
by Jakob77
In general I think "at" works mighty fine but I have a problem making it connect to Wi-Fi.


With a script:

Code: Select all

echo "DISPLAY=:0 netscript on" | at 01:15

With a normal command:

Code: Select all

echo "DISPLAY=:0 nmcli c up WiFimodem-Con_name" | at 01:14

With full path:

Code: Select all

echo "DISPLAY=:0 /usr/bin/nmcli c up WiFimodem-Con_name" | at 01:13

None of them works.

How can that be.? :confused2:

Re: Examples to make "at" work

Posted: Fri Dec 29, 2023 9:40 pm
by DukeComposed
Because you didn't read the man page.

From https://linux.die.net/man/1/at:
at will record the values of environment variables present at time of at invocation. When the commands are run at the specified time, at will restore these variables to their recorded values . These variables are excluded from this processing and are never set by at when the commands are run: TERM, DISPLAY, SHELLOPTS, _, PPID, BASH_VERSINFO, EUID, UID, GROUPS.
Please read the documentation on the tools you are trying to use.

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 2:55 am
by baldyeti
Idk about your wifi issue but DISPLAY is only needed for GUI apps, not CLI.

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 5:32 am
by Jakob77
DukeComposed wrote: Fri Dec 29, 2023 9:40 pm Because you didn't read the man page.

From https://linux.die.net/man/1/at:
at will record the values of environment variables present at time of at invocation. When the commands are run at the specified time, at will restore these variables to their recorded values . These variables are excluded from this processing and are never set by at when the commands are run: TERM, DISPLAY, SHELLOPTS, _, PPID, BASH_VERSINFO, EUID, UID, GROUPS.
Please read the documentation on the tools you are trying to use.


Thank you but I took for granted that everybody already knows it mostly is because I am a fool who don't understand some of the important stuff I read in the manual.
I so much don't want to play hardball with a Unix giant like you because I need your help, but that is why I ask for examples as you can see I do if you read the headline for this subject.

Can you show me an example that can make "at" work with:

Code: Select all

nmcli c up WiFimodem-Connection_name
?

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 6:27 am
by Eadwine Rose
And another example of letting someone else do the work for you. Be careful, because I have warned you before that this forum is not for your personal projects.

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 6:30 am
by baldyeti
Does your command actually work from a terminal ? "WiFimodem-Con_name"" looks like such a generic name ...

Otherwise you can capture the command output/error to try and see why it failed

Code: Select all

echo 'mycommand >/tmp/atcmd.log 2>&1' | at 12:34
Then after the specified time check the content of the log file.

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 9:01 am
by Jakob77
baldyeti wrote: Sat Dec 30, 2023 6:30 am Does your command actually work from a terminal ? "WiFimodem-Con_name"" looks like such a generic name ...

Otherwise you can capture the command output/error to try and see why it failed

Code: Select all

echo 'mycommand >/tmp/atcmd.log 2>&1' | at 12:34
Then after the specified time check the content of the log file.
Thank you, I will look into that. :smile:

I changed the name for forum but the real name works from my Terminal and in scripts and it is used that way many times every day.






By the way I have found another command for "at" that I find useful because it can remove all at jobs that are planned:

Code: Select all

for i in `atq | awk '{print $1}'`;do atrm $i;done



And I believe I might be close to finding a smart way to make "at" run a daily cycle like I want it to.
It makes me dizzy and maybe I need to edit it later but I am so exited about the syntax I just have to share it.
When the time is 13:15 a job start that will set a job at 13:15 the following day:

Code: Select all

echo "DISPLAY=:0 echo sleep 100 && echo "DISPLAY=:0 testscript.sh" | at -M 13:15" | at -M 13:15

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 9:10 am
by Jakob77
Eadwine Rose wrote: Sat Dec 30, 2023 6:27 am And another example of letting someone else do the work for you. Be careful, because I have warned you before that this forum is not for your personal projects.
I am sorry I just completely don't understand.
It scares me you write about a 2. warning and I never understood anything about it. :-(
How can it be a personal project to make a peace of software work in MX, except if you choose to make it personal for personal reasons.?
You can say it is for me as a person but as I see it that goes for almost all forum questions from everybody about software. A person has a project small or big that gives him or her a problem that he or she want's help to solve.
So if you need to warn me about that, won't you also need to give a warning in almost every other subject where a user ask for help.?
To be honest it looks to me as an awful signal to send to the users.
Every time I install MX there comes up a text that tells me to come to forum with my ideas and questions, and without me there would not be any MX-Linux. Have you seen that text.?
I don't know what to believe anymore so please, before you warn me, explain to me what I do wrong, so I can understand it.

Re: Examples to make "at" work

Posted: Sat Dec 30, 2023 9:58 am
by j2mcgreg
Jakob77 wrote: Sat Dec 30, 2023 9:10 am
Eadwine Rose wrote: Sat Dec 30, 2023 6:27 am And another example of letting someone else do the work for you. Be careful, because I have warned you before that this forum is not for your personal projects.
I am sorry I just completely don't understand.
It scares me you write about a 2. warning and I never understood anything about it. :-(
How can it be a personal project to make a peace of software work in MX, except if you choose to make it personal for personal reasons.?
You can say it is for me as a person but as I see it that goes for almost all forum questions from everybody about software. A person has a project small or big that gives him or her a problem that he or she want's help to solve.
So if you need to warn me about that, won't you also need to give a warning in almost every other subject where a user ask for help.?
To be honest it looks to me as an awful signal to send to the users.
Every time I install MX there comes up a text that tells me to come to forum with my ideas and questions, and without me there would not be any MX-Linux. Have you seen that text.?
I don't know what to believe anymore so please, before you warn me, explain to me what I do wrong, so I can understand it.
What you are not getting is that there is an expectation here (and on every other Linux forum) that the people asking questions will have researched their problems first and that the questions being asked are pertinent to the forums where they are posed. Questions on shell scripting are outside the scope of the MX Linux Forums but shell scripting is a basic skill that most Linux users should have in their arsenals. There are plenty of resources on the internet to teach you the ins and outs of shell scripting and had you done your research, you surely would have encountered them. For instance here is an article on the best six free courses on this subject:
https://medium.com/javarevisited/6-free ... 0461ecd4fe
Pick one of them and start learning.

Re: Examples to make "at" work

Posted: Thu Jan 04, 2024 7:32 am
by Jakob77
baldyeti wrote: Sat Dec 30, 2023 6:30 am you can capture the command output/error to try and see why it failed

Code: Select all

echo 'mycommand >/tmp/atcmd.log 2>&1' | at 12:34
Then after the specified time check the content of the log file.

You understand what the topic is about, and I thank you again for the code.
The log file showed that it was about permissions.
I don't know if there are issues of vulnerability that should be considered but otherwise if someone runs into the same problem a possible solution can be found here:
https://forum.xfce.org/viewtopic.php?id=17173


--


DukeComposed

I wish we could have been allowed to fix it among each other like men without interference.
You have helped me before with some magnificent codes I will never forget.
Thank you for that again.

--

Eadwine Rose wrote: Sat Dec 30, 2023 6:27 am And another example of letting someone else do the work for you. Be careful, because I have warned you before that this forum is not for your personal projects.

I have been thinking a lot about this and you haven't answered my last post for you, so I am still hanging in the air.
I don't want to force anybody to answer, especially not when it is about my person like this, but I need to know for sure if it was "just" hard fish slaps to say happy Christmas eve and happy new year to me in a suppressing way, or if you are actually giving me official warnings according to the rules.?
If it is the first I think it is ugly but if it is the last it takes it to a completely other level for me.

--
j2mcgreg wrote: Sat Dec 30, 2023 9:58 am What you are not getting is that there is an expectation here (and on every other Linux forum) that the people asking questions will have researched their problems first and that the questions being asked are pertinent to the forums where they are posed. Questions on shell scripting are outside the scope of the MX Linux Forums but shell scripting is a basic skill that most Linux users should have in their arsenals. There are plenty of resources on the internet to teach you the ins and outs of shell scripting and had you done your research, you surely would have encountered them. For instance here is an article on the best six free courses on this subject:
https://medium.com/javarevisited/6-free ... 0461ecd4fe
Pick one of them and start learning.

I am afraid the only thing I have really failed to understand from you is this:
viewtopic.php?p=717216#p717216
When I look at the pattern and the hostility lately, and how good subjects about Linux are being locked it is confirmed to me that is what it is about, and you actually spoke for the whole administration. If so I have to find a way to live with it but I can only say I think it is very sad for both the users and for MX. And as I mentioned, it is also in strong contradiction to the MX install text.
I think you ought to make a corner somewhere in forum where the users are allowed to discuss their Linux ideas freely until their ears fall off. For some users (me included) a good discussion and sometimes even a bad one is the best way to learn about Linux. To me it is also a social event. I feel I am a part of an important movement with friends where discussions like love will bring us all and Linux up where we belong.

Re: Examples to make "at" work

Posted: Thu Jan 04, 2024 8:10 am
by j2mcgreg
@Jakob77
Let me be succinct. We will not be changing this forum or MX in general to suit your whims.

Re: Examples to make "at" work

Posted: Thu Jan 04, 2024 8:12 am
by Eadwine Rose
And with that, I am closing this topic. Any further things can go via PM.