running script @ startup
running script @ startup
Hi Team,
I want to run a script at the time of system reboot
for root user
/etc/rc.local
/path/of/the/script.sh
for non root user
su - test -c "/path-to-shell-script"
could you please suggest the above mentioned methods are correct?
I want to run a script at the time of system reboot
for root user
/etc/rc.local
/path/of/the/script.sh
for non root user
su - test -c "/path-to-shell-script"
could you please suggest the above mentioned methods are correct?
-
- Posts: 1
- Joined: 2017/12/25 00:07:33
Re: running script @ startup
That'll work but an easier way would be to use cron and specifying a line with:
@reboot (include other details here to run your command)
Check out the man page for crontab:
man 5 crontab
for lots of nifty time options.
(BTW modify the crontab with
crontab -e
(and you can view it with
crontab -l
))
@reboot (include other details here to run your command)
Check out the man page for crontab:
man 5 crontab
for lots of nifty time options.
(BTW modify the crontab with
crontab -e
(and you can view it with
crontab -l
))
Re: running script @ startup
Thanks for your reply but how to apply for my requirement using cron, i need to run only for that particular user @ the time of system startup, also read the man 5 crontab
Re: running script @ startup
crontab -e -u thatuser
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: running script @ startup
Hi Thanks for your suggestion i tried
[root@test ~]# crontab -e -u user
@reboot : "/home/user/test.sh"
still it doesnt work any suggestion
Regards
Kanna
[root@test ~]# crontab -e -u user
@reboot : "/home/user/test.sh"
still it doesnt work any suggestion
Regards
Kanna
Re: running script @ startup
[root@test ~]# crontab -e -u user
@reboot : "/home/user/test.sh"
still it doesnt work any suggestion
i also tried without double quote
@reboot : /home/user/test.sh
@reboot : "/home/user/test.sh"
still it doesnt work any suggestion
i also tried without double quote
@reboot : /home/user/test.sh
Re: running script @ startup
There shouldn't be any colon characters in the crontab file. The line should be:
Check that the file is actually marked executable (chmod +x /home/user/test.sh).
Code: Select all
@reboot /home/user/test.sh
Re: running script @ startup
Thanks a zillion it worked.