3

I wanted to schedule a job with at command and see this error:

    [root@labeir1 exm]# date
    Sun Dec  9 01:54:45 IST 2012
    [root@labeir1 exm]# at 01:47 "df -kh"
    syntax error. Last token seen: d
    Garbled time

Even the same without quotes doesn't work.

Whereas when i schedule the same command to be executed like this:

    [root@labeir1 exm]# echo df -kh | at 01:47
    job 4 at 2012-12-10 01:47

It shows that the job is scheduled, but at that particular time I don't see the output. Is it not that the output will be seen on the console?

5 Answers 5

4

No, the output will not appear on the console.  I would expect the output to be e–mailed to you.  Try

echo df –kh | at –m 01:47

to explicitly ask for e–mail, or

echo "df –kh > df_output.txt" | at 01:47

to write to a file.

1

Try with something like:

mesg y # this is just to make sure you may write to your user
at now + 1 min
at>df -kh | write $USER
at>^D

If that doesn't work, you either haven't got util-linux installed with pty-helper flag enabled or you need to specify the display in which you want the output (it is probably $DISPLAY)

Note that if you do something like:

at now + 1 min
at>xterm
at>^D 

It would probably work if you've got xterm installed (test it with whatever terminal you use). So, I'm guessing that the real problem is that the command is being executed in the background and you need to pull the string you want to prompt and do whatever you need with it (maybe send it to any user with write or wall commands).

1

For people with at problems who searched this post, these are other solutions to check:

MAKE SURE atd SERVICE IS RUNNING

The atd.service might not be running. If you're on an init.d system, enable and start it with:

systemctl enable atd

systemctl start atd

GRAPHICAL APPLICATION ?

If you want to open a graphical application, you will need to enter export DISPLAY=:0.0 in the at command line before entering your command on the next line. After you finish press Ctrl+d to save.

0

Try removing the :, so :

echo 'df -kh' | at 0147
2
  • If you think that the answer is useful, you can 'upvote' it. You can 'accept' the reply too by clicking the outline of the checkmark (will be green), this way, people searching on the website will known that the question is well answered. That's how stackechange websites works, thanks ;) Dec 9, 2012 at 11:34
  • 6
    The confirmation message job 4 at 2012-12-10 01:47 suggests that at is parsing the 01:47 correctly. Dec 11, 2012 at 2:56
0

A bit of a side-note, but as I have always been struggling with the "garbled time" output of at, I'd thought I share my fix for that. My solution is to wrap at in a function and use the, more forgiving, date to fix the garbled time messages.

function at {
  unset IFS
  MOMENT=$*
  AT=$(which at)

  # First try at to see if I finally figured out to produce non-garbled time
  if ${AT} ${MOMENT} 2>/dev/null
  then
    # worked allright, we can exit
    exit
  else
    # We produced garbled time (duh), so let's fix this with date
    MOMENT=$(date --date "${MOMENT}" +'%Y%m%d%H%M')
  fi

  # and try again
  ${AT} -t ${MOMENT}
}

This works best on systems that have GNU date installed (most linux systems).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .