Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
A cron job wouldn't typically have those environment variables set. cron doesn't have the same environment as your user, unless you set it up...typically within the script itself...which means you could just code the actual paths in the command(s)
But yes, please edit your OP to put the code in code tags. Very hard to see what you're actually doing without them. There's a how-to link in my sig
The su -s won't work because it requires a password to be entered. Delete that and run the rest from root's crontab. I have no idea what the rest does, so I can't say if it will work as entered.
If you are trying to start a service at boot time you should create a systemd service and add it to your default target. Using crontab for this is the wrong way. Crontab is for regularly scheduled operations such as backups. It is not for starting services.
additionally would be better to write a script for that command instead of putting it directly into crontab.
replace redirections (instead of /dev/null into a logfile) to see what's wrong.
But as it was mentioned: crontab uses a different environment, so probably your script is unable to run from cron. Also a service should be configured instead.
Yes, I've edited my post with "code". First thank you guys for the responses, much appreciated as other forums didn't even respond. And yeah crontab is a bad option I guess and I even included all the environment variables like "export NLPS_HOME=/path" also I gave full paths without '$ path' and the shell script works fine. But I want this to be executed at the startup. If the shell script works why can't crontab or even a simple systemd service doesn't execute properly? Please enlighten me guys!
You can put the script in /etc/rc.local and it will run at system startup. You will need to edit it to make a proper script, but it shouldn't be that hard.
You can put the script in /etc/rc.local and it will run at system startup. You will need to edit it to make a proper script, but it shouldn't be that hard.
You may not have heard but using /etc/rc.local does not work on systemd installations. The file /etc/rc.local does not even exist on modern systemd Linuxes. You need to create a systemd service to call /etc/rc.local at boot time on systemd installations as well as create the /etc/rc.local bash script file itself and make it executable with chmod.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.