2

I'm trying to set up my system to automatically boot my two main Vagrant boxes when my computer turns on but it's throwing an error saying no such file or directory when I added this to the bottom of ~/.profile

bash cd ~/Develop/Websites/scotch && vagrant up
bash cd ~/Develop/Websites/homestead && vagrant up

I can paste that line (minus the bash) into a terminal though and it works fine.

I'm told I shouldn't use ~/.profile for this and should possibly use a cron @reboot.

How would I format that since it's not a script that runs necessarily? It's not a file you run, it's a command that has to be in a specific folder.

Octoxan
  • 121

1 Answers1

1

It looks like you want to run these commands in a sub-shell to not affect the working directory of the shell running the .profile script.

You can use the -c option to run a shell with commands given on the command line:

bash -c 'cd ~/Develop/Websites/scotch && exec vagrant up'

However, it would be simpler to use the sub-shell feature of the current shell instead:

( cd ~/Develop/Websites/scotch && exec vagrant up )
David Foerster
  • 36,890
  • 56
  • 97
  • 151