I'd like to start Android Studio while my computer starting. I used crontab and @reboot parameter:

crontab -e

and scheduled this task

@reboot /home/ziko/reboot_cron.sh # JOB_ID_1

then in my home dir added script - reboot_cron.sh

echo "It is now $(date +%T) on $(date +%A)" >> cron_reboot.log

After restart my computer I didn't see log in cron_reboot.log and Android Studio wasn't fired. What did I wrong?

UPD. I added second scheduled task and it works


@reboot root /home/ziko/reboot_cron.sh # don't work!
*/5 * * * * /home/ziko/mycrontest.sh   # it works!

And if I manully run reboot_cron.sh then it works but in crontab it don't!

  • In any case you probably need to chuck a shebang line into the first line script file - e.g. #!/bin/sh, #!/bin/bash. – Wilf Dec 9 '15 at 20:00

Did you try "@reboot root su -l ziko sh (script.sh)" from system crontab?

You may not get @reboot to work as non-root.


In system /etc/crontab:

@reboot root su -l (user_to_run_as) (your_sh_script)

or non-root 'crontab -e' user:

@reboot sh (your sh script)

( per : https://askubuntu.com/a/549646/169878 )


Note: I am not entirely sure if you need to be root to execute @reboot properly via crond under Ubuntu or Debian (or for that matter if it needs to be in the system wide crontab). Try the "@reboot sh " first and see if that works as non-root user.. Also consult https://unix.stackexchange.com/q/109804


Unless you really need this executed via crond, it might be a better idea to set this up as an init script (based on runlevel) or rc.local entry.. either one can be executed on a normal startup. Your script will execute after system is completely up. Since you do not need much more control over the script other than having it execute at startup (once), rc.local should be fine.

Example for "rc.local":

sudo nano /etc/rc.local

add this line before 'exit 0':

su -l ziko /opt/android-studio/bin/studio.sh


sudo chmod 755 /etc/rc.local

(Reboot.) 'studio.sh' should have executed/started as the ziko user on startup

  • Downvote with no comment. Uh ok.. My answer/@reboot works in etc system cron for me. If you cannot use root as user running script(s), su user you want script(s) run under (su -l ziko) – B. Shea Dec 9 '15 at 18:56
  • 1
    Hmmm, tried both variants(sh or root), it didn't work for me. Added one more schedule task (*/5 * * * * /home/ziko/mycrontest.sh), it worked as expected. – Alex Zezekalo Dec 10 '15 at 12:50
  • Glad it finally worked. Also - it may simply be a better idea to set this up as a init job or a simple rc.local entry.. either one would get executed on a normal startup. – B. Shea Dec 11 '15 at 16:37
  • And running "@reboot root" will not work out of a non-root crontab -e for obvious reasons. – B. Shea Dec 11 '15 at 16:47
  • Forgot to add: reason that works ^^^^ is you are simply re-executing it every 5mins. Please read what I wrote about possibly using rc.local (or init system) instead or running your script as given user from system crontab. – B. Shea Dec 11 '15 at 17:30

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.