Command works on cli, but not on crontab
Clash 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?
cron logs
 |Â
show 3 more comments
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?
cron logs
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
 |Â
show 3 more comments
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?
cron logs
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
cron logs
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
 |Â
show 3 more comments
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
 |Â
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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