0

I recently discover crontab on my raspberry pi and I wanted to try it so I made different lignes for execute simples programs: $

0 21 * * * /home/pi/Desktop/Programmation/Batch/msg.sh

30 21 * * * /home/pi/Desktop/Programmation/Batch/msg2.sh

0 22 * * * /home/pi/Desktop/Programmation/Batch/msg3.sh

15 22 * * * /home/pi/Desktop/Programmation/Batch/msg4.sh

30 22 * * * /home/pi/Desktop/Programmation/Batch/msg5.sh

35 22 * * * /home/pi/Desktop/Programmation/Batch/msg6.sh
(I know: it's not batch but sh !!) Here is the .sh program (there are all the sames):

#!/bin/bash
echo -e "Hello World !"
sleep 1000000000000000000
But that's doesn't work !! I look on internet and I tried to change the TZ of crontab, I tried the command timedatectl to verify mi date settings :

Local time: sam. 2020-10-10 18:23:37 CEST
           Universal time: sam. 2020-10-10 16:23:37 UTC
                 RTC time: n/a
                Time zone: Europe/Paris (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

And That doesn't work... So please help me !! Thank you very much !!!

Nat' code
  • 55
  • 6
  • If you expect the `echo`s to print to your console, this won't happen. – tkausl Oct 10 '20 at 16:29
  • What do you see in crontab logs? You can find them in `/var/log` directory. – Ilia Kondrashov Oct 10 '20 at 16:35
  • 1
    The output is probably buffered and due to the eternal sleep, never visualised anywhere. You best validate that your programs work with `ps -aux`. If the large number is accepted by sleep, it will most likely still run – kvantour Oct 10 '20 at 16:56
  • but @tkausl when I run msg.sh that work !! The console appear and Isee "Hello World" – Nat' code Oct 10 '20 at 18:23
  • And @kvantour I doesn't understand ps -aux where do I put it ? – Nat' code Oct 10 '20 at 18:23
  • @IliaKondrashov I see many files but no one have cron or crontab on is name – Nat' code Oct 11 '20 at 13:24
  • 1
    @Nat'code here is a good explanation [how to enable and check cron logs on Raspberry](https://raspberrypi.stackexchange.com/questions/3741/where-do-cron-error-message-go), I think it will help you – Ilia Kondrashov Oct 11 '20 at 13:35
  • Aaaah @IliaKondrashov thank you very much, I do that and I modifyed crontab to execute msg.sh at an another hour to test and... Can you help me for th log : ```Oct 11 17:15:01 raspberrypi CRON[4574]: (pi) CMD (/home/pi/Desktop/Programmation/Batch/msg.sh)``` but the cmd doesn't open ! – Nat' code Oct 11 '20 at 15:19
  • 1
    Looks like your `msg.sh` was successully executed. Please note, that cron scripts do not have interactive shell, so you will not see anything in terminal. Good practice is to log both stdout and stderr somewhere - good example can be found [here](https://stackoverflow.com/questions/4811738/how-to-log-cron-jobs) – Ilia Kondrashov Oct 11 '20 at 19:23
  • So @IliaKondrashov there are no way for me to see that the msg.sh as been executed (exept with a log file)? No notification, no terminal or page opened ? – Nat' code Oct 11 '20 at 20:02
  • That's right. Either you makr your script log something on it's own (or log output as I showcased earlier) or you can only verify the result, so check what script was supposed to make. – Ilia Kondrashov Oct 11 '20 at 20:17
  • Ok thank you for our help ! – Nat' code Oct 12 '20 at 15:29

0 Answers0