How the command "at" works?

Peng Yu pengyu.ut at gmail.com
Sat Aug 6 14:46:48 UTC 2016


I don't think just make these changes will make the job run by atd be
aware of any shell function defined in the shell when at is called to
submit the job.

~$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

function my_fun() {
echo "f: $(date)"
}

tmpfile=$(mktemp)
at -t "$(date +%Y%m%d%H%M.%S --date="$time")" <<EOF
date > $tmpfile
my_fun
EOF
~$ ./main.sh
job 123 at Sat Aug  6 00:00:00 2016
~$ at -c 123|grep my_fun
my_fun

The function definition of my_fun is not available in the output of at -c 123.

To support the feature that I need, `declare -f` will need to called
to dump the function definitions to the job scripts shown by at -c,

On Sat, Aug 6, 2016 at 9:31 AM, Karl Auer <kauer at biplane.com.au> wrote:
> On Sat, 2016-08-06 at 06:36 -0500, Peng Yu wrote:
>> Do you know any alternative job scheduler to 'at' with the same
>> fuction but written in a scripting language?
>
> I just downloaded the source and made a version of at/atd that uses
> bash. It took about ten minutes; I just blindly substituted "/bin/bash"
> wherever I found "/bin/sh" in the sources :-)
>
>    apt-get source at
>    sudo apt-get build-dep at
>    cd at-3.1.18
>    ./configure
>    [edit at.c and atd.c]
>    make
>
> I did NOT run "make install". Instead:
>
>    sudo mv /usr/bin/at /usr/bin/at.org
>    sudo mv /usr/sbin/atd /usr/sbin/atd.org
>    sudo cp at /usr/bin/at
>    sudo cp atd /usr/sbin/atd
>    sudo chown daemon:daemon /usr/bin/at
>    sudo ug+s /usr/bin/at
>
> Then:
>
>    sudo systemctl stop atd
>    sudo systemctl start atd
>
> And the top line of a sample job file was:
>
>    #!/bin/bash
>
> To put back the original versions:
>
>    sudo mv /usr/bin/at.org /usr/bin/at
>    sudo mv /usr/sbin/atd.org
> /usr/sbin/atd
>    sudo systemctl stop atd
>    sudo systemctl start atd
>
> Writing this email took substantially longer than getting the modified version of at/atd done, installed and working.
>
> Regards, K.
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Karl Auer (kauer at biplane.com.au)
> http://www.biplane.com.au/kauer
> http://twitter.com/kauer389
>
> GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
> Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4
>
>
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



-- 
Regards,
Peng




More information about the ubuntu-users mailing list