0

I'm currently working on a Linux script on my Raspberry Pi, which should call another script with a time delay. I chose the "at command" for this and let python execute the code directly in the console.

import shlex
import subprocess
subprocess.call(shlex.split("at now + 5 minutes -f /home/raspberry/Desktop/Filename.py"))

When I run the "at command" directly in the console, I get the following feedback:

warning: commands will be executed using /bin/sh
job 13 at Sun Feb 19 23:17:00 2023

Unfortunately, nothing happens at the specified time and the script is not executed. The Filename.py Code is:

#!/usr/bin/env python3
print("Hallo Welt")

Does anyone have any ideas what I forgot or need to do differently?


Reply of /var/spool/mail/raspberry

From raspberry@raspberrypi Sun Feb 19 23:17:00 2023
Return-path: <raspberry@raspberrypi>
Envelope-to: raspberry@raspberrypi
Delivery-date: Sun, 19 Feb 2023 23:17:00 +0100
Received: from raspberry by raspberrypi.fritz.box with local (Exim 4.94.2)
    (envelope-from <raspberry@raspberrypi>)
    id 1pTrzQ-0000we-Fr
    for raspberry@raspberrypi; Sun, 19 Feb 2023 23:17:00 +0100
Subject: Output from your job       13
To: raspberry@raspberrypi
Message-Id: <E1pTrzQ-0000we-Fr@raspberrypi.fritz.box>
From: raspberry@raspberrypi
Date: Sun, 19 Feb 2023 23:17:00 +0100

sh: 47: Syntax error: word unexpected (expecting ")")
hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • Is anything in /var/log/messages or /var/log/syslog? – tdelaney Feb 19 '23 at 22:10
  • I am confused, you say that running in directly in the console doesn't work... so I assume that running through python doesn't work either? – tdelaney Feb 19 '23 at 22:11
  • @Carcigenicate: Yes Shebang is set, hope in correct way, pls have a look at edited question description. – Daniel Stappenbeck Feb 19 '23 at 22:23
  • @tdelaney: There is nothing there that could be related to my problem. – Daniel Stappenbeck Feb 19 '23 at 22:23
  • 2
    where do you expect to see your print? check this answer https://unix.stackexchange.com/questions/82835/why-does-this-at-command-not-print-to-the-standard-output – pmod Feb 19 '23 at 22:23
  • @pmod: Thank you very much, seems to be a syntax error... :-( ??? – Daniel Stappenbeck Feb 19 '23 at 22:31
  • @DanielStappenbeck ok, played a bit with "at" and found this answer in the end, suspected the same: https://stackoverflow.com/questions/3774772/how-to-use-at-command-to-set-python-script-execute-at-specified-time As they suggest it should be : echo python3 home/raspberry/Desktop/Filename.py | at now + 5 minutes – pmod Feb 20 '23 at 15:03

0 Answers0