Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32

Thread: at command launches script

  1. #11
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: at command launches script

    ~/Desktop/Scripts/a.sh is the answer you seek.
    or
    /home/$USER/Desktop/Scripts/a.sh.

    Without any path data as part of the filename, it is going to look in the $PATH. ~/Desktop/ isn't (and shouldn't!!!!) be in your PATH.


    So,

    Code:
    at    -f     ~/Desktop/Scripts/a.sh  now + 2 hours
    Last edited by TheFu; July 17th, 2021 at 08:41 PM.

  2. #12
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,025
    Distro
    Ubuntu Development Release

    Re: at command launches script

    I see TheFu answered, but I'll post anyhow, since I was working on an answer:

    I made an example script called "example":

    Code:
    doug@s19:~/tmp$ cat example
    #!/bin/dash
    
    # example Smythies 2021.07.17
    #       see https://ubuntuforums.org/showthread.php?t=2464962
    #
    
    echo "example ran:" >>example.txt
    date >> example.txt
    and for finding the full path I did:

    Code:
    doug@s19:~/tmp$ find $PWD -name example
    /home/doug/tmp/example
    and so I ran this:

    Code:
    doug@s19:~/tmp$ at now + 1 minute -f /home/doug/tmp/example
    warning: commands will be executed using /bin/sh
    job 3 at Sat Jul 17 12:52:00 2021
    and got this:

    Code:
    doug@s19:~/tmp$ cat example.txt
    example ran:
    Sat 17 Jul 2021 12:03:00 PM PDT
    example ran:
    Sat 17 Jul 2021 12:05:00 PM PDT
    example ran:
    Sat 17 Jul 2021 12:52:00 PM PDT
    Where you see I started this before lunch and finish now after.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  3. #13
    Join Date
    Aug 2006
    Beans
    428

    Re: at command launches script

    So I copied and entered the code

    Code:
    at    -f     ~/Desktop/Scripts/a.sh  now + 2 hours
    (changing the hours to minutes)

    provided by TheFu into Desktop/Scripts.

    And ... it did not work!

  4. #14
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: at command launches script

    #!/bin/bash -x

    output?


    What does : ls -l ~/Desktop/Scripts/a.sh show?

  5. #15
    Join Date
    Aug 2006
    Beans
    428

    Re: at command launches script

    Code:
    -rwxrwxr-x 1 allan allan 595 Jul 15 08:55 /home/allan/Desktop/Scripts/a.sh

  6. #16
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,025
    Distro
    Ubuntu Development Release

    Re: at command launches script

    Quote Originally Posted by TheFu View Post
    #!/bin/bash -x

    output?


    What does : ls -l ~/Desktop/Scripts/a.sh show?
    +1. we need better information than just "And ... it did not work!"

    EDIT: here is mine, showing it is executable by user me:
    Code:
    doug@s19:~/tmp$ ls -l example
    -rwxrw-r-- 1 doug doug 156 Jul 17 11:57 example
    EDIT: I see you posted while I was typing this.
    Last edited by Doug S; July 17th, 2021 at 09:43 PM.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  7. #17
    Join Date
    Aug 2006
    Beans
    428

    Re: at command launches script

    Doug S, I am so sorry but I have no idea what better information I can give you.

    I ran "at".

    It appeared in the atq queue.

    It ran at the appropriate time - disappearing from the atq queue.

    There was no output. For what it's worth the web pages that it was supposed to open, did not.

    If you would like to explain how I can get you the better information that you are looking for that would be very helpful ...

  8. #18
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,025
    Distro
    Ubuntu Development Release

    Re: at command launches script

    Quote Originally Posted by Langstracht View Post
    Doug S, I am so sorry but I have no idea what better information I can give you.
    You provided a wealth of information via this very reply.

    Quote Originally Posted by Langstracht View Post
    I ran "at".

    It appeared in the atq queue.

    It ran at the appropriate time - disappearing from the atq queue.

    There was no output. For what it's worth the web pages that it was supposed to open, did not.

    If you would like to explain how I can get you the better information that you are looking for that would be very helpful ...
    It is a detached process, so no its output would not appear on your terminal.
    I'll modify my example:

    Code:
    doug@s19:~/tmp$ cat example
    #!/bin/dash
    
    # example Smythies 2021.07.17
    #       see https://ubuntuforums.org/showthread.php?t=2464962
    #
    
    echo "example ran:" >>example.txt
    date >> example.txt
    echo "example ran: this goes to console, but does it?"
    and run it manually:

    Code:
    doug@s19:~/tmp$ ./example
    example ran: this goes to console, but does it?
    but that echo to terminal line will not appear via the "at" method:

    Code:
    doug@s19:~/tmp$ at now + 1 minute -f ~/tmp/example
    warning: commands will be executed using /bin/sh
    job 7 at Sat Jul 17 14:04:00 2021
    doug@s19:~/tmp$ atq
    7       Sat Jul 17 14:04:00 2021 a doug
    doug@s19:~/tmp$ atq
    
    doug@s19:~/tmp$ cat example.txt
    example ran:
    Sat 17 Jul 2021 12:03:00 PM PDT
    example ran:
    Sat 17 Jul 2021 12:05:00 PM PDT
    example ran:
    Sat 17 Jul 2021 12:52:00 PM PDT
    example ran:
    Sat 17 Jul 2021 01:27:00 PM PDT
    example ran:
    Sat 17 Jul 2021 01:28:00 PM PDT
    example ran:
    Sat 17 Jul 2021 01:59:00 PM PDT
    example ran:
    Sat 17 Jul 2021 02:02:31 PM PDT
    example ran:
    Sat 17 Jul 2021 02:04:00 PM PDT
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  9. #19
    Join Date
    Aug 2006
    Beans
    428

    Re: at command launches script

    So Doug S, are you saying that "at" is simply not capable of doing what I want - running an ".sh" script which opens web pages?

    If that is not what you are saying then, sorry, but I have no idea what to do with your response.

  10. #20
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: at command launches script

    at sends all output to the locally installed/setup MTA. Then you would use a mail program to see what happened.

    But ... if you are trying to control a GUI program via cron or at, don't. They don't tie into an X/Session or Wayland. If it does work, count yourself lucky. cron and at are meant to work for non-interactive purposes, when no users are logged into the system. If you are trying to run something to popup anything in a GUI, then I think you want a different tool. Look at alarm-clock-applet instead.

    I use at all the time - to launch programs to download stuff from specific locations, at specific times, for specific durations. There are 4 jobs scheduled for today, right now, with 1 of them running currently according to atq.

    I asked for you to add a '-x' option to your bash script, run it, and post the output. Did you miss that?

Page 2 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •