Jump to content

Hi!

 

I use crontab to run a hdparm command at reboot in my Raspberry Pi. I've done it like this:

@reboot sudo hdparm -S120 /dev/sda

My proble is that it only works at reboot (duh!) and when I shut it down and turn it on again it doesn't work. Is there a way to make execute the command when I shut it down and turn it back on?

 

Thanks!

i'm a potato

Link to comment
https://linustechtips.com/topic/122173-crontab-question/
Share on other sites

Link to post
Share on other sites

Sounds like you did it right to me, but why not add it to Root's crontab and eliminate the SUDO or add that command to your SUDO list and allow it to be run by you without a password.

 

Should probably also send the output to a log file.

I roll with sigs off so I have no idea what you're advertising.

 

This is NOT the signature you are looking for.

Link to comment
https://linustechtips.com/topic/122173-crontab-question/#findComment-1628322
Share on other sites

Link to post
Share on other sites

Sounds like you did it right to me, but why not add it to Root's crontab and eliminate the SUDO or add that command to your SUDO list and allow it to be run by you without a password.

 

Should probably also send the output to a log file.

 

I'm on a Raspberry Pi, it doesn't have a root password by default. It works fine but I must reboot in order for it to work. If I shut it down and turn it on again it doesn't work.

i'm a potato

Link to comment
https://linustechtips.com/topic/122173-crontab-question/#findComment-1628348
Share on other sites

Link to post
Share on other sites

I'm on a Raspberry Pi, it doesn't have a root password by default. It works fine but I must reboot in order for it to work. If I shut it down and turn it on again it doesn't work.

 

You don't need a root password, just enter that line for your crontab at the bottom of root's crontab as follows:

 

sudo crontab -e

 

Your default editor will open up with the file for root's crontab listing

then paste your line without the sudo command.

 

Then to see if its there, list root's crontab,

 

sudo crontab -l

I roll with sigs off so I have no idea what you're advertising.

 

This is NOT the signature you are looking for.

Link to comment
https://linustechtips.com/topic/122173-crontab-question/#findComment-1628381
Share on other sites

Link to post
Share on other sites

You don't need a root password, just enter that line for your crontab at the bottom of root's crontab as follows:

 

sudo crontab -e

 

Your default editor will open up with the file for root's crontab listing

then paste your line without the sudo command.

 

Then to see if its there, list root's crontab,

 

sudo crontab -l

 

I'm doing it like that. It  doesn't need sudo? Didn't know that.

i'm a potato

Link to comment
https://linustechtips.com/topic/122173-crontab-question/#findComment-1628411
Share on other sites

Link to post
Share on other sites

I'm doing it like that. It  doesn't need sudo? Didn't know that.

 

If its in root's crontab you don't need sudo, you only need sudo when its under your user environment.

I roll with sigs off so I have no idea what you're advertising.

 

This is NOT the signature you are looking for.

Link to comment
https://linustechtips.com/topic/122173-crontab-question/#findComment-1628547
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×