0

I use webmin for administrate my dedicated server (Centos 7 64 bits) and from there I create cron jobs, I am executing an .sh script as root which contains:

#!/bin/bash


screen -dmS aud
screen -S aud -X stuff "node /home/AuditTrail-Web/app.js
"`echo -ne '\015'`

Cron job execute that script on startup and when I join to that screen using:

screen -r aud

I get something similar to this(maybe named prompt?):

sh-4.2# 

Which does not allow me sometimes to execute some commands like fuser and some other like node /home/AuditTrail-Web/app.js

But if I create the screen manually I get:

[root@Martin ~]#

And that allows me to execute everything.

What is the problem with sh-4.2# and why it is present in that form?

Thank

1

You're defining something in either .bashrc or .bash_profile that you're relying on, especially for the node stuff.

Cron doesn't source/honor either .bashrc or .bash_profile, so those things don't get set when you start the screen.

At least that's my first guess.

  • Is not node, it allways happened me with any script making screens from the cron job, I really do not know why. – Martini002 Sep 22 '16 at 10:52
  • When the cron job execute on startup that bash script I get: sh-4.2# node /home/AuditTrail-Web/app.js sh: node: no se encontró la orden sh-4.2# sh-4.2# – Martini002 Sep 22 '16 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.