This post talks about scripting on raspbian. I have two problems, cron and privilege and running a java script …

cron & privilege

My script, run_aptjob requires sudo authentication and so asks for it from the gui when run from crontab despite being defined in the root crontab file and called using the sudo command.

  1. See https://stackoverflow.com/questions/60754639/sudo-asks-for-password-in-cronjob-script-but-the-same-script-works-without-passw
  2. And https://askubuntu.com/questions/419548/how-to-set-up-a-root-cron-job-properly
  3. https://forums.raspberrypi.com/viewtopic.php?t=296993
  4. https://raspberrypi.stackexchange.com/questions/57835/why-my-script-is-not-executed-with-root-privileges-using-crontab
  5. https://raspberrypi.stackexchange.com/questions/32955/cron-job-doesnt-work-but-runs-successfully-manually, looks like a syntax error

java

I can’t get the script to run from a batch file, I need to set DISPLAY and pass the -input parameter to the command line. It was working but now isn’t.

export DISPLAY=:10.0
java -jar /opt/java/ksar-latest -input ${YESTERDAY}

This code works from the command line where $YESTERDAY is yesterday’s SAR text file.

Does DISPLAY need to be passed over using the -D flag?

Otherwise, I found these,

  1. https://unix.stackexchange.com/questions/226008/how-to-pass-arguments-to-a-java-process-from-within-a-shell-script
  2. https://stackoverflow.com/questions/8123058/passing-on-command-line-arguments-to-runnable-jar
  3. how to get a .jar to display its options, usually java -jar ${jarfile} –help should work, it did for me.
  4. This on duckduckgo gave a number of options

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.