1

I am working on a VM with Lubuntu 14.04,

I have created a script a.sh,

#!bin/bash
echo "aaaa" >> a.txt

And my /etc/rc.local file is as follows:

#!/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.

bash /home/sentinel/a.sh
echo "hey" >> /home/sentinel/b.txt
exit 0

On rebooting my machine, I can see b.txt built with content as hey but a.txt is not being built. Can somebody please help me here?

1
  • No, b.txt doesn't exist. By built I mean created. That means second last line of the rc.local is executed, but 3rd last isn't. @JacobVlijm Sep 5 '14 at 8:17
8

Mention complete path where a.txt should create.

Your script should be:

#!/bin/bash
echo "aaaa" >> /home/sentinel/a.txt

I have tried this my self before posting here .

added line rc.local as

./home/sentinel/a.sh

save it and restart your PC.

5
  • 1
    Did you mean . /home/sentinel/a.sh instead of ./home/sentinel/a.sh? The first is doing source using an absolute path, the second executes the script by a relative path. Sep 5 '14 at 9:25
  • 3
    Do you even bash, bro? Sep 5 '14 at 10:32
  • I just tried this on my computer, and it doesn't seem to work. I copied everything as mentioned here, still didn't work. Any ideas?
    – IcyFlame
    May 10 '15 at 22:39
  • How you are trying ?
    – rɑːdʒɑ
    May 11 '15 at 2:04
  • @Daniel , I am trying to help with what i know and here i am , where you are then...i too have a pc and i can type anything. If possible encourage,guide,help else shut your mouth and hands. Thanks for stopping by.
    – rɑːdʒɑ
    May 11 '15 at 13:11
3

Missing leading / char.

#!bin/bash

should be

#!/bin/bash
1
  • 1
    Sharp! however, since he is calling the script with bash /home/sentinel/a.sh it works anyway... So he escaped luckily. Sep 5 '14 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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