Command works on cli, but not on crontab

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have script that is doing an iperf3 test against a server and is piping it into a file. Then I have this command, that takes makes a line for a logfile.
It works when executing on the command line, but not when it's running from crontab.



#!/bin/bash
printf "%s%sn"
"$(TZ=CEST date -d "$(head -1 some.log)" "+%y-%m-%d %H:%M:%S")"
"$(grep sender iperftmp.log | awk -F"] " 'print $2')" >>
/data/div/sh/somenew.log


In crontab it looks like this:



46,36,21,06 * * * * /bin/bash /path/to/print.sh >/dev/null 2>&1


I have tried many ideas in crontab -e, but it gives me the same error:



18-09-13 00:00:00


It should be:



18-09-13 15:20:11 0.00-10.00 sec 5.15 GBytes 4.42 Gbits/sec 1570 sender 


Would you please advice?










share|improve this question



















  • 2




    Useful in these situations: unix.stackexchange.com/a/56503/117549
    – Jeff Schaller
    Sep 13 at 13:30










  • I would start by directing stdout and stderr to a file, and maybe see actual error.
    – Archemar
    Sep 13 at 13:42










  • I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
    – jnj
    Sep 13 at 13:52










  • What implementation and version of cron are you using?
    – Philippe
    Sep 13 at 13:58











  • check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
    – Alexander
    Sep 13 at 14:00














up vote
0
down vote

favorite












I have script that is doing an iperf3 test against a server and is piping it into a file. Then I have this command, that takes makes a line for a logfile.
It works when executing on the command line, but not when it's running from crontab.



#!/bin/bash
printf "%s%sn"
"$(TZ=CEST date -d "$(head -1 some.log)" "+%y-%m-%d %H:%M:%S")"
"$(grep sender iperftmp.log | awk -F"] " 'print $2')" >>
/data/div/sh/somenew.log


In crontab it looks like this:



46,36,21,06 * * * * /bin/bash /path/to/print.sh >/dev/null 2>&1


I have tried many ideas in crontab -e, but it gives me the same error:



18-09-13 00:00:00


It should be:



18-09-13 15:20:11 0.00-10.00 sec 5.15 GBytes 4.42 Gbits/sec 1570 sender 


Would you please advice?










share|improve this question



















  • 2




    Useful in these situations: unix.stackexchange.com/a/56503/117549
    – Jeff Schaller
    Sep 13 at 13:30










  • I would start by directing stdout and stderr to a file, and maybe see actual error.
    – Archemar
    Sep 13 at 13:42










  • I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
    – jnj
    Sep 13 at 13:52










  • What implementation and version of cron are you using?
    – Philippe
    Sep 13 at 13:58











  • check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
    – Alexander
    Sep 13 at 14:00












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have script that is doing an iperf3 test against a server and is piping it into a file. Then I have this command, that takes makes a line for a logfile.
It works when executing on the command line, but not when it's running from crontab.



#!/bin/bash
printf "%s%sn"
"$(TZ=CEST date -d "$(head -1 some.log)" "+%y-%m-%d %H:%M:%S")"
"$(grep sender iperftmp.log | awk -F"] " 'print $2')" >>
/data/div/sh/somenew.log


In crontab it looks like this:



46,36,21,06 * * * * /bin/bash /path/to/print.sh >/dev/null 2>&1


I have tried many ideas in crontab -e, but it gives me the same error:



18-09-13 00:00:00


It should be:



18-09-13 15:20:11 0.00-10.00 sec 5.15 GBytes 4.42 Gbits/sec 1570 sender 


Would you please advice?










share|improve this question















I have script that is doing an iperf3 test against a server and is piping it into a file. Then I have this command, that takes makes a line for a logfile.
It works when executing on the command line, but not when it's running from crontab.



#!/bin/bash
printf "%s%sn"
"$(TZ=CEST date -d "$(head -1 some.log)" "+%y-%m-%d %H:%M:%S")"
"$(grep sender iperftmp.log | awk -F"] " 'print $2')" >>
/data/div/sh/somenew.log


In crontab it looks like this:



46,36,21,06 * * * * /bin/bash /path/to/print.sh >/dev/null 2>&1


I have tried many ideas in crontab -e, but it gives me the same error:



18-09-13 00:00:00


It should be:



18-09-13 15:20:11 0.00-10.00 sec 5.15 GBytes 4.42 Gbits/sec 1570 sender 


Would you please advice?







cron logs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 13 at 13:36









Goro

5,47052460




5,47052460










asked Sep 13 at 13:25









jnj

274




274







  • 2




    Useful in these situations: unix.stackexchange.com/a/56503/117549
    – Jeff Schaller
    Sep 13 at 13:30










  • I would start by directing stdout and stderr to a file, and maybe see actual error.
    – Archemar
    Sep 13 at 13:42










  • I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
    – jnj
    Sep 13 at 13:52










  • What implementation and version of cron are you using?
    – Philippe
    Sep 13 at 13:58











  • check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
    – Alexander
    Sep 13 at 14:00












  • 2




    Useful in these situations: unix.stackexchange.com/a/56503/117549
    – Jeff Schaller
    Sep 13 at 13:30










  • I would start by directing stdout and stderr to a file, and maybe see actual error.
    – Archemar
    Sep 13 at 13:42










  • I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
    – jnj
    Sep 13 at 13:52










  • What implementation and version of cron are you using?
    – Philippe
    Sep 13 at 13:58











  • check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
    – Alexander
    Sep 13 at 14:00







2




2




Useful in these situations: unix.stackexchange.com/a/56503/117549
– Jeff Schaller
Sep 13 at 13:30




Useful in these situations: unix.stackexchange.com/a/56503/117549
– Jeff Schaller
Sep 13 at 13:30












I would start by directing stdout and stderr to a file, and maybe see actual error.
– Archemar
Sep 13 at 13:42




I would start by directing stdout and stderr to a file, and maybe see actual error.
– Archemar
Sep 13 at 13:42












I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
– jnj
Sep 13 at 13:52




I did this: 46,36,21,51 * * * * /data/div/sh/print.sh &> /tmp/fehler But it shows nothing
– jnj
Sep 13 at 13:52












What implementation and version of cron are you using?
– Philippe
Sep 13 at 13:58





What implementation and version of cron are you using?
– Philippe
Sep 13 at 13:58













check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
– Alexander
Sep 13 at 14:00




check paths to some.log and iperftmp.log, and make them full, not just filenames, as in cron you have different workdir, then normally
– Alexander
Sep 13 at 14:00















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468795%2fcommand-works-on-cli-but-not-on-crontab%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468795%2fcommand-works-on-cli-but-not-on-crontab%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay