# Problem executing script through at

**URL:** <https://community.unix.com/t/problem-executing-script-through-at/237004>\
**Category:** Shell Programming and Scripting\
**Created:** [April 5, 2009, 11:17am UTC](https://community.unix.com/t/problem-executing-script-through-at/237004 "2009-04-05T11:17:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![viktor4124](https://community.unix.com/letter_avatar/viktor4124/32/6_449c533f586939b6e5f246632a46421f.png) [@viktor4124](https://community.unix.com/u/viktor4124)\
**Post date:** [April 5, 2009, 11:17am UTC](https://community.unix.com/t/problem-executing-script-through-at/237004/1 "2009-04-05T11:17:36Z")

</div>

Hey fellows,

i've got a probkem while executing a command through a scheduled at-job;  
Somehow my script starts looping, when triggered throug at;  
It doesnt do so if started manually.  
Any ideas?

```plaintext
#!/bin/sh
# atrun uid=33 gid=33
# mail www-data 0
umask 22
cd /var/django/webripper/ripper || {
     echo 'Execution directory inaccessible' >&2
     exit 1
}
set -o xtrace ; mplayer -dumpstream mms://stream1.orf.at/fm4_live -really-quiet -dumpfile /var/www/media/recordings/test.wmv < /dev/null &> /dev/null & 
MPID=$! ; echo $$ > /var/www/media/recordings/test.pid ; 
echo $MPID $$ $! ; 
sleep 60 ;
kill $MPID ; 
exit 0 ;

```

here's the output when xtrace is enabled:

```plaintext
Subject: Output from your job 20
To: www-data

+ mplayer -dumpstream mms://stream1.orf.at/fm4_live -really-quiet -dumpfile /var/www/media/recordings/test.wmv
+ MPID=20360
+ echo 20357
+ echo 20360 20357 20360
20360 20357 20360
+ sleep 60
+ ev/null
+ MPID=22321
+ echo 20357
+ echo 22321 20357 22321
22321 20357 22321
+ sleep 60

```

I have no idea where the

```plaintext
ev/null

```

is coming from, neither why the whole thing starts looping.

> [@](#):
>
> /bin/sh --version  
> GNU bash, version 3.1.17(1)-release (x86\_64-pc-linux-gnu)  
> Copyright (C) 2005 Free Software Foundation, Inc.
> 
> at -V  
> at version 3.1.9  
> Bug reports to: [rmurray@debian.org](mailto:rmurray@debian.org) (Ryan Murray)  
> Garbled time

I'm using Debian 4.0 btw.

thanks in advance for any advice  
viktor

---

<div class="post-metadata">

**Author:** ![vidyadhar85](https://community.unix.com/user_avatar/community.unix.com/vidyadhar85/32/997_2.png) [@vidyadhar85](https://community.unix.com/u/vidyadhar85)\
**Post date:** [April 5, 2009, 10:20pm UTC](https://community.unix.com/t/problem-executing-script-through-at/237004/2 "2009-04-05T22:20:52Z")

</div>

can you paste the how you are starting this job with at command  
and kill $MPID won't kill the process it will just stop the process if you wanna kill use  
kill -kill pid or kill -9 pid

---

<div class="post-metadata">

**Author:** ![viktor4124](https://community.unix.com/letter_avatar/viktor4124/32/6_449c533f586939b6e5f246632a46421f.png) [@viktor4124](https://community.unix.com/u/viktor4124)\
**Post date:** [April 6, 2009, 1:56pm UTC](https://community.unix.com/t/problem-executing-script-through-at/237004/3 "2009-04-06T13:56:08Z")

</div>

when starting manually I do it the followin way:

```nohighlight
# sudo -u www-data /bin/sh atjob_xtrace.sh 
+ mplayer -dumpstream mms://stream1.orf.at/fm4_live -really-quiet -dumpfile /var/www/media/recordings/test.wmv
+ MPID=5693
+ echo 5692
+ echo 5693 5692 5693
5693 5692 5693
+ sleep 60
+ kill 5693
+ exit 0

```

starting through at involves:

```nohighlight
# sudo -u www-data at now -f atjob_xtrace.sh 
warning: commands will be executed using /bin/sh
job 22 at Mon Apr 6 19:51:00 2009

# cat /var/spool/cron/atspool/a00016013b1aaf 
Subject: Output from your job 22
To: root

+ mplayer -dumpstream mms://stream1.orf.at/fm4_live -really-quiet -dumpfile /var/www/media/recordings/test.wmv
+ MPID=20321
+ echo 20318
+ echo 20321 20318 20321
20321 20318 20321
+ sleep 60
+ dev/null
+ MPID=21911
+ echo 20318
+ echo 21911 20318 21911
21911 20318 21911
+ sleep 60

```

edit: ah, ja and atjob\_xtrace.sh is the script shown in my first post

thx in advance  
viktor
