automate commands at startup

Issues related to applications and software problems and general support
Post Reply
Posts: 51
Joined: 2012/07/06 23:57:24

automate commands at startup

Post by edwardsmarkf » 2021/04/10 17:48:49

hello -

i need to run several command at bootup. according to some forums, the best place to put them is in a cron:

Code: Select all

@reboot  ( iptables -I INPUT 1 -p tcp --dport 10000 -j ACCEPT ;  mkdir  /var/lock/bash/ ; mount --bind /home /var/www ;  )
i see that the commands are being acknowledged in `/var/log/cron` but they dont seem to be doing anything. i have to go in and manually do them from root after a reboot.

please advise.

User avatar
Forum Moderator
Posts: 30650
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: automate commands at startup

Post by TrevorH » 2021/04/10 17:58:12

There are alternate and preferred ways of doing those things. On CentOS 8 the default firewall is firewalld and you can add persistent rules to that using the firewall-cmd comand. Many of us think that firewalld is a huge bloated pig that has no place on a a server and prefer to use either nftables directly (which is the iptables replacement in CentOS 8) or use the iptables -> nftables wrapper which allows you to add rules using the iptables command that are then translated to nftables internally.

If you choose to use the iptables wrapper then it uses the same file in CentOS 8 as it did in CentOS 7 and you can add persistent rules to the /etc/sysconfig/iptables file, in the same format that you'd use to run the iptables command but minus the 'iptables ' bit of it on the front.

You can bind mount things directly from /etc/fstab, no need to run a separate mount command to do so.
CentOS 6 died in November 2020 - migrate to a new version!
Info for USB installs on
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply

Return to “CentOS 8 - General Support”