Results 1 to 3 of 3

Thread: At command

  1. #1
    Join Date
    Mar 2005
    Location
    Isle of Bute, Scotland
    Beans
    369
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    At command

    I am having problems with this command.
    I have a python script which I have been playing with and what it does is mail me a message.
    Now if I run it directly it works fine but I wanted a regular reminder so I thought I might use the 'at' command

    To test it out I tried these:
    at -t 03271658 `./runmyscript.py`
    at -t 03271658 `/home/norman/runmyscript.py`
    at -t 03271700 -f ./runmyscript.py
    at -t 03271700 -f /home/norman/runmyscript.py
    but none of them work.

    I can do the following:
    at now + 1 min `echo Hello> ./hello`warning: commands will be executed using /bin/sh
    at> ^C

    cat hello
    Hello

    at now + 1 min `echo goodbye> ./hello`
    warning: commands will be executed using /bin/sh
    at> ^C
    cat hello
    goodbye
    I know there are other ways but I would like to get this working. Any ideas please?
    Running 14.04 on my HP Pavilion g6 4 Gig Ram 320 Gig Disc

  2. #2
    Join Date
    May 2010
    Location
    uk
    Beans
    9,324
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: At command

    Hi

    Two points; use ctrl + d to schedule the job, not ctrl + c. This will send the EOT character to at. Be aware it's using sh and not bash to run any scripts.

    Code:
    matthew-S206:/home/matthew % at now + 1 min
    warning: commands will be executed using /bin/sh
    at> echo hello > /home/matthew/test1
    at> <EOT>
    job 14 at Wed Mar 27 20:17:00 2013
    matthew-S206:/home/matthew % cat test1
    hello
    matthew-S206:/home/matthew %
    Also the at command is similar to cron in that it does not have the environment your user has.

    Let me give you an example.

    To play the gangnam style video, i can navigate into my Music directory and type

    Code:
    matthew-S206:/home/matthew/Music % pwd
    /home/matthew/Music
    matthew-S206:/home/matthew/Music % mplayer PSY_-_GANGNAM_STYLE_강남스타일_M_V-9bZkp7q19f0.mp4
    This will quite happily play the video.

    However this, using at, this will not work

    Code:
    matthew-S206:/home/matthew/Music % at now + 1 min                                            
    warning: commands will be executed using /bin/sh
    at> mplayer PSY_-_GANGNAM_STYLE_강남스타일_M_V-9bZkp7q19f0.mp4
    at> <EOT>
    job 15 at Wed Mar 27 20:22:00 2013
    matthew-S206:/home/matthew/Music %
    That is because it is missing some of my environment.

    This, however, will run the video

    Code:
    matthew-S206:/home/matthew % at now + 1 min
    warning: commands will be executed using /bin/sh
    at> DISPLAY=:0 /usr/bin/mplayer /home/matthew/Music/PSY_-_GANGNAM_STYLE_강남스타일_M_V-9bZkp7q19f0.mp4
    at> <EOT>
    job 16 at Wed Mar 27 20:23:00 2013
    matthew-S206:/home/matthew %
    I have supplied full paths and the DISPLAY environmental variable. Make sure you are supplying everything at needs to run your script

    I hope that helps.

    Incedently, i have used at and mplayer as an alarm clock in the past.

    EDIT:

    I think you know this from your first post but i thought i would mention it for any others looking at this thread who do not know.

    You can pipe commands into at.

    Code:
    echo DISPLAY=:0 /usr/bin/mplayer /home/matthew/Music/PSY_-_GANGNAM_STYLE_강남스타일_M_V-9bZkp7q19f0.mp4 | at now + 1 min
    Kind regards
    Last edited by matt_symes; March 27th, 2013 at 10:14 PM. Reason: typo
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  3. #3
    Join Date
    Mar 2005
    Location
    Isle of Bute, Scotland
    Beans
    369
    Distro
    Ubuntu Gnome 14.04 Trusty Tahr

    Re: At command

    Thanks Matt
    /home/norman/runmyscript.py | at -t 03272233
    did the job.
    I hadn't thought about the environment
    Running 14.04 on my HP Pavilion g6 4 Gig Ram 320 Gig Disc

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
  •