Solved root or userland for cron job

May someone can help me out. I want to use a script everytime my machine boots up. Execute before even the splash screen pops up. As I am the single user, I could set it as root in the crontab /etc/crontab following the handbook, so it would act for each other user. If I do so, do I set it as a executable shell-script or as a command?

e.g.

Code:
/etc/crontab                    * * * * * @reboot myscript.sh
for root or
Code:
/usr/home/name/bin/       * * * * * @reboot my sequence of commands

thanks in advance
 
It may be worth mentioning what this script does and why you want it. This sounds like a typical X-Y Problem.

How you execute the script is up to you. Executing it directly requires it to be set as executable and have its directory in the $PATH of the user running it.
 
If I do so, do I set it as a executable shell-script or as a command?

It is up to you. Anyway, you must use absolute paths to commands :

Code:
@reboot /sbin/ifconfig ...

or set PATH first and use the short names:

Code:
@reboot ifconfig ...

If not so, it will behave different as your shell - commands will not be found.

Oops, I'm editing.... forgot something:

/etc/crontab you may set PATH here. I remembered, because I tested what I just said to you and was surprised it worked.... it depends on what commands you are calling, they must be in PATH to be found . But the absolute path for the command is guaranteed to work.

Cheers,
 
It should change the MAC -address before connecting to wired or wireless network.

No scripting required. /etc/rc.conf will let you set the MAC address for an interface before it is brought up for use.

(Virtually) anything you can do at the command-line with ifconfig(1) can be done in the ifconfig_*= lines in /etc/rc.conf.

Code:
ifconfig_em0="ether ab:cd:ef:01:23:45"
ifconfig_em0_alias0="DHCP"

The first line gets run first and can be used to set any options that will reset the card. The second line can then be used for actually setting the IPs and whatnot.
 
Back
Top