Results 1 to 4 of 4
I ran into a problem when wanting to execute the "at" command from within a cron job.
Essentially, I have a daily crontab job that is launched at "the wrong ...
- 03-03-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
Problems running "at" command within a cronjob
I ran into a problem when wanting to execute the "at" command from within a cron job.
Essentially, I have a daily crontab job that is launched at "the wrong time" (middle of night). I want to delay the execution of an import script until around 07:00. Editing the crontab is not an option (shared environment).
So I figured: Use the "at" command from within my script that is triggered (indirectly) by crontab:I know my script is started with `pwd` pointing at that same directory.Code:#!/bin/bash at -f ./redo_import.sh -v 07:00
Running the "at" command directly from terminal works.
Running the script file above from terminal works.
But... when triggered from within crontab it does not work. I get exit code "1" from "at".
I searched man pages for "at" without much success. No mention of meaning of exit codes.
Now I wonder if someone has an idea why this is happening. Or how to locate the sources of the "at" command.
Thanks.
- 03-03-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,977
Just a guess, but sometimes this sort of problem is due to the detached nature of the processes shell started by cron (no stdin/stdout/stderr). You might try redirecting the input and output of the 'at' command inside your script to see if that helps.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-03-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
Solved
I got some help locally and of course answer was easy.
"at" only reported to stderr and I was not logging that. Only the exit code, which could mean anything.
The current path (pwd) inside the cronjob was not what I expected. When cactching stderr message... it was easy to solve.
- 03-03-2011 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,977
So, basically what I said...
Glad you got it sorted out.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote