LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   crontab (https://www.linuxquestions.org/questions/linux-general-1/crontab-559652/)

tux_processor 06-06-2007 12:04 PM

crontab
 
Hi everybody,

I am facing a problem with crontab . When I am trying to redirect the standard output for qshape(for postfix queue) command, file is created but there are no contents in the file.

The crontab entry is:

Code:


*/1    *    *    *    *      /usr/bin/qshape > log.txt


now the file log.txt is created with no contents, However if I run the command

Code:

  qshape > log.txt

I find certain contents in the file.

Can anybody help me out?

thanks in advance.

trickykid 06-06-2007 12:05 PM

What does this command do exactly?

Try doing:

*/1 * * * * /usr/bin/qshape >> log.txt

tux_processor 06-06-2007 12:32 PM

When I tried


Code:

*/1    *    *    *    *      qshape 2> log.txt

i.e. redirecting the error. I found
Code:

/bin/bash: command not found

actually qshape command was located in /usr/sbin/.

thanks anyway!

trickykid 06-06-2007 08:28 PM

Quote:

Originally Posted by tux_processor
When I tried


Code:

*/1    *    *    *    *      qshape 2> log.txt

i.e. redirecting the error. I found
Code:

/bin/bash: command not found

actually qshape command was located in /usr/sbin/.

thanks anyway!

Ok so in your first response you have your crontab listing the command in /usr/bin and now it's in /usr/sbin

Why did you try it without the full complete path? When dealing with cron and crontab, it's always a good practice to put the full complete path of the command.

If it's located in /usr/sbin, perhaps having it /usr/bin was the problem, but I'm just totally confused with your followup, it made no sense to me on if you're still having problems, solved it, etc.

tux_processor 06-07-2007 12:55 AM

Hi!!

The problem was very specific to the command , I think. When I type "qshape" on shell I get:

Code:

  T  5 10 20 40 80 160 320 640 1280 1280+
                             
  TOTAL  0  0  0  0  0  0  0  0  0    0    0


it shows status of postfix queues.
I found my problem solved with the crontab entry :


Code:

*/1    *    *    *    *      /usr/sbin/qshape -c /etc/postfix /var/spool/postfix/active > /root/log3.txt
where /etc/postfix is the configuration directory and /var/spool/postfix/active is the queue directory.

While typing it on console , it takes these directories by default and in crontab it gives the error.

trickykid 06-07-2007 10:10 PM

Quote:

Originally Posted by tux_processor
Hi!!

The problem was very specific to the command , I think. When I type "qshape" on shell I get:

Code:

  T  5 10 20 40 80 160 320 640 1280 1280+
                             
  TOTAL  0  0  0  0  0  0  0  0  0    0    0


it shows status of postfix queues.
I found my problem solved with the crontab entry :


Code:

*/1    *    *    *    *      /usr/sbin/qshape -c /etc/postfix /var/spool/postfix/active > /root/log3.txt
where /etc/postfix is the configuration directory and /var/spool/postfix/active is the queue directory.

While typing it on console , it takes these directories by default and in crontab it gives the error.

Hence the reason when dealing with crontab, take in account that it most likely won't be using the same environment, paths, etc that the user uses, so always use full complete commands.. ;)


All times are GMT -5. The time now is 11:32 PM.