I have created a test user with admin permissions. I put following entry in /var/spool/cron/crontabs/test file
* * * * * sh /vmfs/volumes/datastore1/my_dir/my script.sh
I am trying to run my_script to start some other programs if they are not running already
by running following command in a loop for each program name in MONITORED_PROGRAMS="program1.sh, program2.sh"
isRunning=$(ps -Tcjstv | grep $programName | grep -v grep)
and starting the program if it is not running by
nohup sh /vmfs/volumes/datastore1/my_dir/$PROGRAM 2>&1 nohup.$PROGRAM &
The my_script works fine if it is called from root crontab ( /var/spool/cron/crontabs/root )
But when I call it through /var/spool/cron/crontabs/test , ps command does find the pid even if the program is running.
so it ends up in spawning multiple processes that keep increasing until it runs out of memory.
So I would like to know why it works from root crontab and not from a different user(test in this case) crontab.
How do I fix this?
Thanks