Awk command giving issue for .service file execution
I have centos 7. Thus in the /lib/systemd/system I created a new .service as below.
When I am using awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' this command in it does not execute the command. But when I run from command prompt that works fine. Quote:
Quote:
|
What's in journalctl -xe ?
A systemd status=127 means "unknown command" -- try using absolute paths to all commands and files: Code:
/bin/bash /usr/local/serverBash_11000.sh | /bin/awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' | /sbin/rotatelogs /usr/local/server11000 |
I suggest putting the entire command in a script using absolute paths as suggested, make it executable and call the script from the service file.
|
Quote:
|
Hi Scasey & Michaelk,
Actually currently my serverBash_11000.sh is as below. So your suggestion is as to add the command in this bash ? Or should I create another script and put the command in it and leave this script as it is? Sorry a bit confused here. Quote:
|
Quote:
(Note: should have the absolute path to clear and java in that script as well) If not, then create a new script containing the commands you already have and ExecStart that script. |
Hi Scasey,
I notice using the awk piping I do miss some earlier missing example when I start my application it get connection pooling. May 26, 2019 2:52:03 AM com.zaxxer.hikari.HikariDataSource <init> INFO: HikariPool-1 - Starting... May 26, 2019 2:52:04 AM com.zaxxer.hikari.HikariDataSource <init> INFO: HikariPool-1 - Start completed. But this is not shown in the logs file. Just to confirm must I create a file called service.log first? Quote:
Quote:
|
Quote:
|
Hi Scasey,
Just wonrdering what I did correct and efficient right. I created another .sh file and in it I put this /bin/bash /usr/local/serverBash_11000.sh | /bin/awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' | /sbin/rotatelogs /usr/local/server11000. So automatically this calls the serverBash_11000.sh bash file. You were saying regarding clear I should use the path I dont get you on that or should I remove the clear key word? |
Quote:
You said that serverBash_11000.sh contained a clear command and a java command. All I was saying is that you should use absolute paths to those commands as well. That insures the commands can always be found. I don't know exactly what you're trying to accomplish, so I don't know if the clear command is appropriate.. |
Hi Scasey,
Sorry for me missing on the code tag earlier. Actually what I am trying to achieve is previously I used to have a java daemon wrapper to run a socket server based on java. Since the wrapper have not been update and has issues on new centos 7, thus I did a research and found this new method using service so I am very new to it and learning . I used to use monit to monitor it incase it goes down and able to email me. Hope I am clearer now. |
newbie14: to me, java is coffee :) I’ve given all the help I can here.
Please mark the thread SOLVED if you think it is. |
Hi Sean,
Yes sure I have marked it has been helpful I will put more queries when I face more issues. |
All times are GMT -5. The time now is 07:50 AM. |