Examples to make "at" work  [Solved]

Message
Author
Jakob77
Posts: 661
Joined: Thu Feb 09, 2023 3:09 am

Examples to make "at" work

#1 Post 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)

User avatar
baldyeti
Posts: 730
Joined: Sat Dec 05, 2009 3:37 pm

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

#2 Post 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

User avatar
towwire
Posts: 688
Joined: Fri Oct 15, 2010 12:15 pm

Re: Examples to make "at" work

#3 Post 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.
It is easier to fight for one's principles then to live up to them.

Jakob77
Posts: 661
Joined: Thu Feb 09, 2023 3:09 am

Re: Examples to make "at" work

#4 Post 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.

Jakob77
Posts: 661
Joined: Thu Feb 09, 2023 3:09 am

Re: Examples to make "at" work

#5 Post 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:

Jakob77
Posts: 661
Joined: Thu Feb 09, 2023 3:09 am

Re: Examples to make "at" work

#6 Post 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:

User avatar
DukeComposed
Posts: 1507
Joined: Thu Mar 16, 2023 1:57 pm

Re: Examples to make "at" work

#7 Post 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.

User avatar
baldyeti
Posts: 730
Joined: Sat Dec 05, 2009 3:37 pm

Re: Examples to make "at" work

#8 Post by baldyeti »

Idk about your wifi issue but DISPLAY is only needed for GUI apps, not CLI.

Jakob77
Posts: 661
Joined: Thu Feb 09, 2023 3:09 am

Re: Examples to make "at" work

#9 Post 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
?

User avatar
Eadwine Rose
Administrator
Posts: 15285
Joined: Wed Jul 12, 2006 2:10 am

Re: Examples to make "at" work

#10 Post 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.
MX-23.6_x64 July 31 2023 * 6.1.0-39amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.247.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

Locked

Return to “Software / Configuration”