Ubuntu – Why the ‘at’ clause command execute the shell immediately and ignored the time limit

at-commandbashcommand line

I wrote a shell named t.sh It's content is:

touch 88888

The command I'm using is

sh t.sh | at 03:13Jun15

After I execute this command, I got this show on my screen:

warning: commands will be executed using /bin/sh
job 9 at Sun Jun 15 03:13:00 2014

It shows quite clear that this will be executed at Sun Jun 15 03:13:00 2014

But when I check my folder, and I find a 88888 file exists there. Rmoved it and try agian, still the same result.

What's the problems here? Would it be a bash/sh thing? Because I saw it says will execute by /bin/sh?

Best Answer

at reads commands from standard input, or from a file if you specify the -f flag. What sh t.sh | at [time] does is:

1. execute the shell script t.sh *right now*; 
2. pipe the output of the shell script to at. 

But the script has no output, so there is nothing to execute on Sunday.

What you want is at 03:13Jun15 -f t.sh.