script not working when invoked via cron - shell

I have created a script script.sh which contains
./ecc start pricingUpdater & >> /home/eceuser/Muthu/details/Latest.txt
where ecc is another script.
If I run the script manually by simply invoking ./script.sh I am able to start the utility:
Starting Oracle Communication Elastic Charging Controller 11.2.0.1 ...
-- Node 'pricingUpdater' started with PID 10705
^[[1m===>^[[m [{GridEventImpl
status: true
node: PricingUPdater node pricingUpdater on Host 10.180.85.16
details: [pid:10705, state:running]
}]
but if I try to run the same script via crontab I get:
Starting Oracle Communication Elastic Charging Controller 11.2.0.1 ...
so the utility is not started.

It seems that you are running the cron jobs with user which doesn't have permission to edit or create /home/eceuser/Muthu/details/Latest.txt file

Related

In Oozie, how I'd be able to use script output

I have to create a cron-like coordinator job and collect some logs.
/mydir/sample.sh >> /mydir/cron.log 2>&1
Can I use simple oozie wf, which I use for any shell command?
I'm asking because I've seen that there are specific workflows to execute .sh scripts
Sure, you can execute Shell action (On any node in the Yarn cluster) or use the Ssh action if you'd like to target specific hosts. You have to keep in mind that the "/mydir/cron.log" file will be created on the host the action is executed on and the generated file might no be available for other Oozie actions.

How do I make a Bash script run continously, also end it when I want to?

I have a Bash script that creates a private Geth node named "startnode.sh".
I want to be able to run this script on a server and exit that server without any problem.
You are looking for nohup(1).
It is a utility which let's you detach a process from your current terminal session.
Here's a link to a manual of a FreeBSD nohup(1).
Alternatively, set up a systemd .service file and have it run as a daemon
https://wiki.archlinux.org/index.php/Systemd

How can I run a Shell when booting up?

I am configuring an app at work which is on a Amazon Web Server.
To get the app running you have to run a shell called "Start.sh"
I want this to be done automatically after booting up the server
I have already tried with the following bash in the User Data section (Which runs on boot)
#!/bin/bash
cd "/home/ec2-user/app_name/"
sh Start.sh
echo "worked" > worked.txt
Thanks for the help
Scripts provided through User Data are only executed the first time the instance is started. (Officially, it is executed once per instance id.) This is done because the normal use-case is to install software, which should only be done once.
If you wish something to run on every boot, you could probably use the cloud-init once-per-boot feature:
Any scripts in the scripts/per-boot directory on the datasource will be run every time the system boots. Scripts will be run in alphabetical order.

How do I write script to start multiple services in centos?

I am having multi-node cluster of Hadoop, Kafka, Zookeeper, Spark.
I am running following commands to start respective service,
$ ./Hadoop/sbin/start-all.sh
$ ./zookeeper/bin/zkServer.sh start
$ ./Kafka/Kafka-server-start.sh ./config/server-properties.sh
$ ./spark/sbin/start-all.sh
and so on..
can anyone tell me how to write a script to automate this process of running each command individually?
Have you tried creating a simple shell script with all these commands and running that script instead? For example, following is a simple bash script
#!/bin/bash
./Hadoop/sbin/start-all.sh
./zookeeper/bin/zkServer.sh start
./kafka/kafka-server-start.sh ./config/server-properties.sh
./spark/sbin/start-all.sh
and so on ...

How to write shell script to restart tomcat7 automatically using cron?

I am very new to shell script,in my company i need restart all application servers in production at or before 12.30 pm everyday.can i automate this process by shell script also will it affect any other application running on the server.
Thanks in Advance
At last i found answer to restart tomcat automatically by writing a simple script and setting-up that script on cron whatever time sequence i need restart application server.
Script
#! /bin/sh
SERVICE=/etc/init.d/tomcat7
$SERVICE restart
Cron job
30 12 * * * /root/restarttomacat.sh
It wont affect any other applications.

Resources