2

I'm using a beaglebone black which works with Debian 8.6. I want to start a program after reboot. I tried crontab but it didn't work.

@reboot sleep 60 && /home/debian/acspilot/start.sh

Program consists of a config.sh file and a acsp.py python script. Each code works fine from terminal. Here are the codes:

start.sh:

#!/bin/sh
sudo su
cd home/debian/acs/
./config_pins.sh
python acsp.py

config_pins.sh :

#! /bin/bash
cd /sys/devices/platform/bone_capemgr
File=slots
if grep -q "Override Board Name,00A0,Override Manuf,univ-emmc" "$File"; 
then    
        cd
        echo -e "\nHooray!! configuration available"
        echo -e "\n UART 4 configuration p9.11 and p9.13"
        sudo config-pin P9.11 uart
        sudo config-pin -q P9.11
        sudo config-pin P9.13 uart
        sudo config-pin -q P9.13
        echo -e "\n UART 1 configuration p9.26 and p9.24"
        sudo config-pin P9.24 uart
        sudo config-pin -q P9.24
        sudo config-pin P9.26 uart
        sudo config-pin -q P9.26
        echo -e "\n UART 5 configuration p8.38 and p8.37"
        sudo config-pin P8.38 uart
        sudo config-pin -q P8.38
        sudo config-pin P8.37 uart
        sudo config-pin -q P8.37
        echo -e "\n UART configuration end" 
else    
        echo "Oops!!configuration is not available"
        echo "Please check uEnv.txt file and only disable HDMI"
fi

acsp.py:

import Adafruit_BBIO.PWM as PWM
import Adafruit_BBIO.UART as UART
import time
# UART communication begins
UART.setup("UART1")
# pwm begins
PWM.start("P9_14", 5,50)
ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
while ser.isOpen():
      for i in range(1,99)
            print i
            ser.write(str(i)+"%")
            PWM.set_duty_cycle("P9_14", i)
            time.sleep(5)
ser.close()
UART.cleanup()
PWM.stop("P9_14")
PWM.cleanup()
1

The script has a sudo'ed line, and if it is cronned to a non-root user, the shell cannot be executed by itself. Instead you should first be root with

sudo su -

And then

crontab -e

as root user and add the task line

|improve this answer|||||
  • it didnt worked for me – acs Dec 14 '16 at 22:34
  • To recommendations: – Serhat Cevikel Dec 15 '16 at 1:45
  • Two recommendations: First, you can delete the "sudo su" line out. Second, change cd home/... to cd /home/... – Serhat Cevikel Dec 15 '16 at 1:46
  • Furthermore, is config_pins.sh executable with chmod +x? – Serhat Cevikel Dec 15 '16 at 1:47
  • And you may use absolute paths for config_pins.sh and acsp.py – Serhat Cevikel Dec 15 '16 at 1:48

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.