Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

Try removing the :, so :

echo 'df -kh' | at 0147
share|improve this answer
    
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 ;) – Gilles Quenot Dec 9 '12 at 11:34
4  
The confirmation message job 4 at 2012-12-10 01:47 suggests that at is parsing the 01:47 correctly. – Scott Dec 11 '12 at 2:56

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.

share|improve this answer

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).

share|improve this answer

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.