-1

So, basically I am using wiringPI library and its sample code for ds1302 chip. It works great by the way - writing and reading to and from ds1302 chip is a breeze. I can initiate PI's date and time update with ds1302 date and time and vice versa. I want to automate this process for boot-time and periodic update of ds1302 chip with PI's date and time. I got the boot-time PI's date and time update from ds1302 date and time by calling a script at boot.

For periodic update of ds1302 date time from PI's date time, I am using sudo crontab -e The script itself is working as expected but not updating my ds1302 chip's date time. In the crontab, I have the following.

* * * * * date>>/home/pi/script/cron.txt
* * * * * sudo ./home/pi/script/ds1302 -sdsc

I know crontab is working, because I do see cron.txt with time stamp for every minute, but the ds1302 chip date time has not updated to the PI's date time. The weird thing is that if I were to execute the command, sudo ./home/pi/script/ds1302 -sdsc on the terminal, it WORKS instantly. So, why won't crontab run the command or having difficulty running the command?

7
  • 2
    This is a duplicate. You have been told before to use absolute paths in crontab. Anything starting with a . is not an absolute path.
    – joan
    Commented Jun 21, 2016 at 19:25
  • @joan The reason I have . in the beginning is to execute ds1302 program. dot followed by absolute path /home/pi/script/.
    – ThN
    Commented Jun 21, 2016 at 19:27
  • 2
    You have changed an absolute path to a relative path. Get rid of the dot.
    – joan
    Commented Jun 21, 2016 at 19:28
  • 1
    You need to look online for a Linux tutorial to explain such things as absolute and relative paths.
    – joan
    Commented Jun 21, 2016 at 19:36
  • 1
    You really need to look through a Linux tutorial. It will cover many similar things to this which will catch you out until you understand what is going on.
    – joan
    Commented Jun 21, 2016 at 19:55

1 Answer 1

1

Just remove the dot

* * * * * sudo /home/pi/script/ds1302 -sdsc

1
  • 1
    You have answered your own question based on @joan comments which is a bit cheeky - you could have at least mentioned here help/comments. Second you have not explained what the removing the dot does and why it worked - this would show you understood the problem and solution not just repeated the advice you were given. Commented Jun 21, 2016 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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