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.
- See https://stackoverflow.com/questions/60754639/sudo-asks-for-password-in-cronjob-script-but-the-same-script-works-without-passw
- And https://askubuntu.com/questions/419548/how-to-set-up-a-root-cron-job-properly
- https://forums.raspberrypi.com/viewtopic.php?t=296993
- https://raspberrypi.stackexchange.com/questions/57835/why-my-script-is-not-executed-with-root-privileges-using-crontab
- 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,
- https://unix.stackexchange.com/questions/226008/how-to-pass-arguments-to-a-java-process-from-within-a-shell-script
- https://stackoverflow.com/questions/8123058/passing-on-command-line-arguments-to-runnable-jar
- how to get a .jar to display its options, usually java -jar ${jarfile} –help should work, it did for me.
- This on duckduckgo gave a number of options