1

I am trying to use the feature of "at" command to schedule the execution of any specific command at some user defined time. Wondering if its possible using "at" command. I am hoping "at" could help me because I do not have privileges to schedule a cron task.

Things I have tried :

user>touch testfile |at 03:00  
job 30 at 2014-12-31 03:00  
user>ls -lrt testfile  
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile  <-----file created with command execution  
user>  

user> touch testfile1 | at -f 03:01
Garbled time
user>ls -lrt testfile*
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile
-rw-rw-r--  1 user group 0 Dec 31 02:59 testfile1
2
  • 1
    When you do not have privileges for cron, than you shouldn't have for "at" either. Before making a solution with at, ask your sysop about the security policy: Will they revoke your rigths for "at" in the future? I would prefer granted rights for cron, since that makes things clear for the sysop (otherwise you might write your own cron-process with sleeps...) Commented Dec 31, 2014 at 11:26
  • thanks for warning , I will get the sysop's view on this. Commented Jan 1, 2015 at 7:45

1 Answer 1

3

Use:

echo "touch testfile" | at 03:00

You're running touch testfile immediately, and piping its output to at. The input to at should be the command you want to run, not the output of the command.

If you want to run multiple commands, use a here-doc:

at 03:00 <<EOF
touch testfile
touch testfile1
EOF
Sign up to request clarification or add additional context in comments.

1 Comment

After setting your at command to run at a specified time, you can check what is scheduled to run in your queue using the atq command. This allows a small confirmation that the system at least intends to run your command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.