LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   crontab sh issues (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-sh-issues-4175504489/)

logspalding 05-09-2014 02:46 PM

crontab sh issues
 
Simply put, crontab throws the "No such file" exception when creating a job to run a bash script @reboot. Here's what I did:

Created this script:

#!/bin/bash
clear
cd /home/admin
echo "Initializing..."
/home/admin/proc_ret.sh


Then, chmod 755 to change permissions to executable

Then, simply: crontab @reboot /home/admin/script.sh, which throws the exception.

I've also tried: crontab * * * * * @reboot... and crontab sh /home/admin/script.sh (this doesn't throw an exception, but it doesn't create a task, i.e. crontab -l shows nothing.

ANY IDEAS?

MensaWater 05-09-2014 04:07 PM

Quote:

crontab @reboot /home/admin/script.sh
:confused:

To setup a crontab entry you run "crontab -e" which puts you into an edit (vi) session. You then input your detailed entry:
Code:

@reboot /home/admin/script.sh
and save then exit.

That adds the entry to the crontab file in /var/spool/cron for the user you ran the command as. (e.g. /var/spool/cron/root if you did it as the root user.)

The @reboot per "man 5 crontab" replaces the standard 5 date/time specifications so you don't add the * * * * * in addition to the @reboot.

logspalding 05-09-2014 04:17 PM

Thanks
 
Thanks - yes, I realize now that I missed that essential step!

Thanks,

*thread closed*

Firerat 05-09-2014 04:59 PM

Personally, I would chmod 700

No reason for anyone but owner (admin?) Execute (or read ) it


Of course, root will also be able to do what it wants with said script


All times are GMT -5. The time now is 07:34 PM.