# at does not work



## Simdor (Jul 16, 2014)

Hi,

I do not get how the at command works.  The goal is to use at with the -m option (http://www.freebsd.org/cgi/man.cgi?query=at&sektion=1) and then use mailx to see the "output". But even the simple `echo "hello" |at -m 16:22 16.07.2014` does not work. It then says 
	
	



```
Job # will be executed using /bin/sh
```
 but `at -l` shows that the job does not get executed at the given time.

If I execute the above command without the -m option the job also does not get executed but disappears from the queue a few minutes after the set execute time.

Any help would be gladly appreciated.


----------



## talsamon (Jul 16, 2014)

Try:


```
user@machine:~% at 19:55 16.07.2014
>echo hello
>Ctrl-d
```


----------



## talsamon (Jul 16, 2014)

Strange...sometimes it works, sometimes not ?


----------



## talsamon (Jul 16, 2014)

```
user@machine~% sudo at 20:43 16.07.2014
DISPLAY=:0 lxterminal
Ctrl-d
```

works, but it seem not to work with `echo`. It's something with the Enviroment.


----------



## Simdor (Jul 16, 2014)

Thank you for your reply @talsamon it really helped me. Yes, it seems like it has something to do with the `echo` command not working. `ls | at -m 22:00 16.07.2014` works just fine. *A*lso it seems like it can only handle some of the basic commands and that only without any options.


----------



## junovitch@ (Jul 16, 2014)

`echo "hello" | at ...` means that it will try to execute the command hello, which there is none.  I think you are going for `echo 'echo "hello"' | at ...`.


----------



## talsamon (Jul 17, 2014)

*B*ut 
	
	



```
echo "echo hier" >> echo.txt| at 01:06 17.07.2014
less echo.txt 
echo hier
```
and that leads to the solution:

```
echo "echo hier" > /dev/pts/1 |at 1:32
echo hier
```


----------



## junovitch@ (Jul 17, 2014)

talsamon said:
			
		

> but:
> `echo "echo hier" >> echo.txt| at 01:06 17.07.2014`



Should probably be `echo "echo hier >> echo.txt" | at 01:06 17.07.2014` if I am understanding you correctly.  You can look under /var/at/jobs/xxxx where the xxxx is some string to look at the actual script and see the environmental variables and commands that actually get put in.  It's just a shell script and all right there to look at.  You shouldn't have to be guessing or using much trial and error.


----------



## junovitch@ (Jul 17, 2014)

Another option using here document style strings.


```
at 0530am <<EOF
echo hello1
echo hello2
echo hello3
EOF
```


----------

