Hi

When I setup a cron job like this crontab -e

*/1 * * * * echo $A_VARIABLE > /home/user/Desktop/test.txt

no problem, the file is created whether the variable exist or not.

BUT doing

*/1 * * * * cd /Path/To/Script && Script.sh
#The Script.sh
echo $A_VARIABLE > /home/user/Desktop/test.txt

Do not generate the file ! and The CRON log give me

(CRON) info (No MTA installed, discaring ouput)

and yes, the  Script.sh has the execution bit.

Any ideas ?

Thanks.

  • I_Am_Jacks_____@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    edit-2
    2 months ago

    If . or /path/to/Script are not in your crontab’s PATH variable, it cannot find the script. If the script is in /path/to/Script, change your crontab to either:

    */1 * * * * cd /Path/To/Script && ./Script.sh
    

    Or

    */1 * * * * /Path/To/Script/Script.sh
    

    Also, “*/1” means every 1 minute and “*” means every minute, so the “/1” is unnecessary

  • Anna@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    2 months ago

    I see you already got the answer. But if you are new to Linux I’d suggest to play overtwire bandit. This will significantly improve your Linux command knowledge.

  • Juno@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    2 months ago

    User permissions? I’m no pro, but when running the script it might not have the right permissions for /home/user/? Hopefully someone smarter at this can teach us both…