0

in ubuntu at startup i want to run command just ask user to enter a number.

this command should run recursive in while loop. after user enter a number

a php program process it and again ask user for enter an another number. i have this script runs perfectly.

then put this script in rc.local file to run at startup. when i manually run "exec rc.local" command it works fine.

but when i restart my system to execute command at startup nothing happen.

i expected after startup a terminal window open and ask for number input, Just like what occurs after running the file manually.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

set -x                         # tell sh to display commands before execution

while true; do php /var/www/html/eventica/artisan SendRfid:send; sleep 0; done

exit 0
  • Replace php by /usr/bin/php. – Jos Sep 20 '16 at 19:00
  • as i said script works good when i call it with exec command. – mohammad rezvani Sep 21 '16 at 14:23
0

I'm not able to test it. But I assume that you can create a .sh file and run it on boot via crontab.

set -x                         # tell sh to display commands before execution

while true; do php /var/www/html/eventica/artisan SendRfid:send; sleep 0; done

exit 0

Make a .sh file and save it. (For example, /etc/myscript.sh) Test run it. If you get a Permission Denied error, run chmod +x /etc/myscript.sh

If it works, you can use profile.d to run the script on logon.

ln -s /etc/myscript.sh /etc/profile.d/myscript.sh

That creates a symbolic link to profile.d.

  • didn't worked for me. nothing happen after startup. i expected to automatically open new terminal window after startup and run predefined command, but nothing happen. – mohammad rezvani Sep 24 '16 at 3:21
  • @mohammadrezvani Does it work if you run the .sh script? – mg20023 Sep 24 '16 at 11:04
  • yes it work when run .sh – mohammad rezvani Sep 24 '16 at 18:15
  • @mohammadrezvani I've updated the answer. Try that. – mg20023 Sep 25 '16 at 20:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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